Sail Boat Simulation

 

Contents:

Purpose
Building the program
Running the GUI
Problems

Purpose

I tried to use actual physics for sailing but the math was quite difficult. I simplified the equations in order to implement them.  I used euler integration for the movement of the boat and Runge-Kutta  for the integration of the spray.  I modeled the boat my self and then using an import-export program called milk shape exported it into open GL.  Milk shape exported my model as a list of vertices and normals which I could then traverse through and draw my objects.  A few of my goals for the project were, to have a realistic sailing simulation.  Represent the ocean with waves, and allow the user to control the navigation of the boat.   

Building the program

I developed the program in MS visual C++ 6.0 programming environment, and a unix programming environment.  Before you build the program in unix or in MS visual C++ 6.0 , you must open up the gui.fl using fluid and use the write command located under the file menu. This will produce gui.cxx and gui.h. Now that you have gui.cxx and gui.h you can build the project from the command line under unix.  Assuming that the proper complier, fltk and openGL libraries are installed, you can simple type make at the command prompt in the directory the program files are located in. This will create "sail_boat", an executible program.  In windows you have to load the project file then type f7 or click on the build button.  When the project is built it creates an executeible file that can be run by typing [control f5]. This will bring up the program.

Running the GUI

You should now see something similar to this.

You have the choice to change via slider several  different parameters from the scene.  The wave height and length change the sea as you would think. The height makes swells higher, while the length makes the waves longer.  You are able to change the magnitude of the wind, which will in turn cause the boat to heel and sail faster.  The easiest navigation is with the preset points of sail, reach, weather and down wind. You may also use the tack button to change the direction of the boat.  For realistic navigation you can use the rudder and the sheet, which affect the boat direction and the trim on the sail.   The run toggle allows you to start and stop the animation.  The restart button re-centers the boat. The orange triangle that appears above the boat is a wind glyph depicting both wind direction and magnitude. 

Below are a few screen shots that were my favorite.

   

movie link

Problems

    I had several problems with the physics of sailing.  I ended up coming up with my own physics  for the simulation purposes.  The basic variables that I used for simulating sailing were.  The direction of the boat, simply determined by the rudder position.  The amount the sails were trimmed.  The force the wind was putting on the boat, both causing the boat to tilt and causing the boat to move.  The sway of the waves causing to boat to tilt.  These variables are calculated in my b_position function.   I also had trouble generating water.  I ended up using a sin function to create the sway and using a little bit of randomness to change the color and the normals.  The end effect is not exactly water but for my purposes it is pretty good.