Classic Computer Magazine Archive CREATIVE COMPUTING VOL. 9, NO. 7 / JULY 1983 / PAGE 206

Animated hi-res sailboat. Peter Schug.

Twenty years ago I invested three months and about four hundred dollars in my first sailboat. Then, armed with a copy of The Penguin Book of Sailing by Peter Heaton, I set forth in my homemade Windmill class sloop to investigate just what does happen when the wind is abaft the beam with the boom athwartships and the vang is slackened off. (As soon as I could find out what a vang was.)

Now, face wizened by the sun and salt spray, sitting in front of my Apple, the old lore in the Heaton book percolates upward from some long dormant recesses of my brain. I think back across the span of years to the vector diagrams in the opening chapters and wonder if I can implement them on my screen.

In approximately the same length of time as it took twenty years ago, I built my second homemade sailboat.

I remember wondering why it took so long the first time also.

The program was conceived as a sailing tutorial that produces an animated vector diagram to illustrate the forces acting on a sailboat in motion. Somewhere along the way, I decided it would be nice to be able to sail a boat around the screen. After all, it's more fun to sail than to read a book about it and you can learn more by doing (or simulating) than by trying to understand someone else's vector diagrams.

Thus was born the idea of a two-dimensional animated graphic hi-res simulation of a displacement hull with a trimmable sail and steerable rudder.

The program runs in either a moving boat mode, or a vector diagram mode. The choice is given at the beginning, but M or V can be pressed at any time to toggle the display. It makes sense to use the moving boat mode to start, then set up a situation (like beating to windward, running, setting the sails too tightly, etc.) then toggle to the vector mode and look at the operating forces.

Run the program and the boat will be drawn facing into the wind (10 kts coming out of the north). After a couple of cycles the boat will start drifting back slowly (as in leaving a mooring) and if you put the tiller hard over (paddle 0) the boat will start turning broadside to the wind. The sail is controlled by paddle 1 and should be fully until the boat has turned about 60[deg.] counterclockwise from the wind. Then sheet in the sail (paddle 1 clockwise) and straighten out the rudder. Since the screen updates are rather slow, make the adjustments and wait a couple of cycles to see their effect or you may tend to over-control.

On the bottom of the screen you will see a legend that bears these titles each followed by a number.

HEADING

MAKING GOOD

SPEED KTS

SAIL ANGLE

APPARENT WIND

ANGLE TO BOAT

They translates as follows:

HEADING is the direction the boat is pointed.

SPEED KTS tells how fast the boat is going.

MAKING GOOD is the direction the boat is actually moving. Sailboats go a little sideways due to the force of the wind. The sideways motion is called leeway. The course made good includes leeway, therefore is not the same as the heading.

SAIL ANGLE is the angle at which the wind hits the sail. Positive numbers indicate starboard tack (meaning the wind is coming over the right side of the boat) and negative indicate port (wind coming over left side). The range is 0[0] to 180[deg.]. Specifically, it is not the sail freedom nor is it the angle of the sail to the boat.

APPARENT WIND is the strength of the wind as it is felt on the boat. The vector sum of the forward motion of the boat and the speed of the wind add up to a strength and direction that is not the same as the real wind. Ask someone who has been sailing downwind with a large genoa on a breezy day, then turned around and tried to beat to windward.

ANG TO BOAT is the angle of the apparent wind to the centerline of the boat. Once again, positve numbers indicate starboard and negative numbers port with a range of 0[deg.] to 180[deg.].

Between the information in the legend and the image of the boat moving across the screen, you can get a fair idea of how a boat sails.

For an even closer look, you can type V and toggle to the vector diagram mode. In this mode there are two boats on the screen. The one on the left shows the real wind, which is the vertical line going to the center of the boat, the motion of the boat, which is the line furthest from the real wind, and the apparent wind, which is the line between the other two.

On the right diagram I show the lift force generated by the sail, which is the line closest to the front of the boat (unless you are sailing by the lee). The rearmost line, often too small to be seen, is the drag force, and the line between them is the total force of the wind on the boat.

Not shown in the diagram are the lift and drag characteristics of the hull and how it resolves the force of the wind into forward motion. I just assume a twenty to one L/D ratio (which means that the boat is twenty times harder to move sideways than forward).

The display on most Apples can be stopped with a CTRL-S allowing a careful study of a single frame.

Some definitions are in order before I explain how the program works. I will call the sail an airfoil in the sense that anything that interacts with moving air may be so described. Airfoils posses two significant characteristics, lift and drag, both of which may be measured at various angles of attack (sail angles in this program).

Lift is a force at 90[deg.] to the wind. The program calculates the lift of the sail by multiplying the square of the apparent wind by a number selected by the sail angle from an array that represents the lift characteristic of the sail (see Figure 1).

Drag is a force in line with the wind. Drag force is calculated in a manner similar to lift using a sinusoidal curve (see Figure 2) starting at a base value that represents the windage of the hull and spars and hits a peak at 100[deg.], then drops back to the base value again (100[deg.] degrees instead of 90 because I set the minimum drag to 10[deg.] since the luffing sail has a higher drag than the sail that has just stopped luffing).

The sine function of Basic is used to generate an appropriate array that covers 180[deg.] of operation. The values in both arrays are arbitrary. Only the relationship of the value of one angle to another and the relationship of the value of the arrays to each other are significant.

The arrays that represent the lift and drag characteristic of the sail are speculative, but in concept I believe them to be fair representations of the actual lift and drag curves of a real sail (see Figure 3).

The program is relatively straight-forward and with the aid of the variable table should be understandable with some study. The init section is at the end of the program. When the program goes into hi-res mode, the screen chops the back of the program off. Beware of this. Do not save the program after running it because it is not all there.

The subroutines that do the turtle graphics and the vector calculations are both written in map convention, with 0[deg.] at the north and numbers increasing clockwise, instead of 0[deg.] being east and the numbers increasing counter-clockwise. I hope that explains the non-standard arrangement of sine versus cosine.

The jibe routine beginning at line 1720 and the acceleration section at line 2790 may require some thought but the only thing that needs explanation is the purpose of the routine at lines 2550 to 2580 which is to keep the boat from responding to changes in sail trim with sudden large changes in leeway.

A careful look at the program will show that shortcuts have been taken in the interest of speed and simplicity. My sincere apologies to the laws of physics for some of these. The goal of this simulation is realistic and predictable performance. The approach I took was to find an appropriate imitation of the behavior of a boat, rather than a painstaking model of each facet of the problem. I hope you like it. Happy sailing.