
Show HN: Sail boat simulation – try to sail into the wind - imakesnowflakes
http://imakesnowflakes.com/fun/sail.html
======
krschultz
A little improvement in the graphics would make this much more intuitive.

#1) Which is the front end of the boat? Not that hard to have a pointed end
and a not pointy end.

#2) The sail shouldn't go all the way around, nor rotate around its center. If
you are approximating something like a Laser it can go through about a 210
degree arc. Other boats, more like 120-160 degrees.

#3) So the wind is coming from the left? Note that almost all things generally
show the fluids as streamlines, so at first glance it seemed to me that the
wind was coming from the top and the boat was moving to the left.

#4) It's missing the force vector from the boat in the water. That's what
really explains what is going on. The force vectors don't add up to the motion
shown.

~~~
imakesnowflakes
Great suggestions.

>It's missing the force vector from the boat in the water. That's what really
explains what is going on. The force vectors don't add up to the motion shown.

Yes. You see, I couldn't really isolate that vector. What I am doing is taking
the force vector on the sail and taking the projection of it in the direction
that the boat is facing. Actually, the forward force comes from the boat
trying to move in the direction of the force of the sail. But ends up moving a
bit forward because the keel is in a slanted direction to that movement. So
even if I show that vector, the viewer probably wont still have any idea
regarding where it came from.

~~~
pkghost
This is a neat idea, but it's super confusing without the concept of the
sail's curvature.

AFAIK, sails work like airplane wings (not like socks), creating lift on the
convex surface by virtue of faster moving air and lower pressure. Perhaps your
model assumes the same, but it's not clear from the way the sail is drawn, and
it looks like sailing down wind is just as fast as sailing somewhat across the
wind, which is in fact the fastest way to sail.

~~~
Sharlin
Airplane wings don't work like that; it's a common myth and does not really
make sense. Wings generate lift by a rather straightforward utilization of
Newton's third law of motion: they deflect air downward. Sails work the same
way: they deflect air sideways.

[http://www.cam.ac.uk/research/news/how-wings-really-
work](http://www.cam.ac.uk/research/news/how-wings-really-work)

~~~
Anderkent
Video that (i think) explains it better:
[https://www.youtube.com/watch?v=aFO4PBolwFg](https://www.youtube.com/watch?v=aFO4PBolwFg)

------
tiffanyh
For those of you stating you'd like something a bit more realistic, try:

[http://www.thepirateking.com/ships/sail_simulator.htm](http://www.thepirateking.com/ships/sail_simulator.htm)

@imakesnowflake, great work btw.

~~~
jontas
This isn't working for me (just hangs on Loading..) using up to date Chrome on
OSX. Anyone else having better luck?

~~~
dzhiurgis
Works for me.

Maxxed out 9.25 knots at close haul at 33 knots of wind.

------
joshuaheard
This is a good start, but the physics of sailing is much more complex than
presented in your app. For instance, a sailboat is not powered by the wind
pushing on the sail.

It works like this. The wind is split by the leading edge of the sail (the
mast, headstay, or luff). It is split into two turbulent streams, one on each
side of the sail. One stream has slightly less force on the sail so the sail
begins to move in that direction. As the flow stabilizes over that side, the
wind moves faster on that side than on the turbulent side. This creates lift
like an airplane wing. So the wind is actually pulling the sail, not pushing
it.

Lift on the sail causes the boat to heel (lean over). Some of the lifting
force is counterbalanced by the keel underwater keeping the boat upright. The
remainder of the force pushes the boat downwind. However, the flat keel
underwater prevents the boat from sliding downwind, with the result that the
boat is forced forward.

I recommend you read this book for your next version:

[http://www.amazon.com/Sail-Power-Complete-Guide-
Handling/dp/...](http://www.amazon.com/Sail-Power-Complete-Guide-
Handling/dp/0394727150)

~~~
theothermkn
This is the strangest folk non-explanation of lift I've ever encountered.

> So the wind is actually pulling the sail, not pushing it.

A handy distillation of fluid dynamics is, "Just like you can't push string,
you can't suck fluids." That is, fluids don't resist in tension except in very
particular very dynamic conditions that are wholly outside of the realms where
our intuitions are developed. It looks like you've inadvertently modified the
popular "Bernoulli's Principle" theory of lift, which was wrong even before
you modified it.

There's no real point in doing anything like a rebuttal, so let me do the best
I can, instead, to explain how lift is actually developed and how that applies
to the case of a sailing vessel.

The fundamental thing that makes lift possible is the Kutta condition. This
states that a real fluid has to leave a cusp in the direction that the cusp
faces. There are complicated reasons for this having to do with velocity
gradients, viscosity, radius of curvature of the flow, and even relativity,
but the layperson can observe, feel, or take on faith that a flow leaves an
edge in a direction parallel to the edge. This fact literally turns the flow
and results in lift. (Historically and physically, we say that the Kutta
condition resolves D'Lambert's Paradox via the Kutta-Jukowski theory of lift,
if you want some keywords to look up more information.)

So, the direction of the trailing edge of the flow turns the flow. There are
two ways that we can examine the result of this: momentum or pressure. It
turns out that they give the exact same result for the lift of an airfoil, but
are "intuitive" in different ways. The momentum theory just says, "Lift is
just a force that is accounted for by the mass of the air that you're pushing
aside. This is what you typically might call 'downwash'," but a bit more
mathematically. The pressure theory says, "Look, that's all fine, but that
force is experienced as a pressure distribution on a surface, because the only
part of the wing that's in the flow is the surface. Let's keep track of
(integrate) the pressure over the surface and see what the resulting forces
are," but also a bit more mathematically.

So, take your pick of intuitions: Imagine a wing throwing air or fluid aside,
or imagine it experiencing a pressure difference from top to bottom. They're
both true, and are just different ways of accounting for the same phenomenon,
different procedures for accounting for forces and masses as they interact
with "control volumes," as engineers and physicists like to say. And remember
that both intuitive explanations are driven by the Kutta condition, which is
far more interesting, I think, than the erroneous Bernoulli explanation.

So, that's lift. I turn a flow and I get a reaction force. Peachy. How does it
apply to sailboats?

Other than the buoyancy force and gravity, every force that we care about on a
sailboat is due to the operation of a foil (hydrofoil or airfoil) within a
fluid (water or air). The hull of the boat, the rudder, and the keel act like
wings of (typically very low) efficiency. Their total lift acts to resist the
downwind drift of the boat in the water. The sail acts as a wing. Depending on
the point of sail, the lift of the wing acts more or less, literally, in the
direction of travel of the boat. (Close to the wind, the majority of the lift
is actually wasted in heeling the boat over and trying to slide it downwind.)

I know I said that a rebuttal would be unproductive, but there are a few
things I suddenly can't resist.

> However, the flat keel underwater prevents the boat from sliding downwind,
> with the result that the boat is forced forward.

The "flat keel" is a wing. It prevents this "slide" via lift. It's also not
helpful to split the analysis into 'forces' and 'constraints'. The keel
produces lift that is a fore that contributes to the balance of forces on the
vessel, resulting in motion.

> [The wind] is split into two turbulent streams, one on each side of the
> sail.

Turbulence is a complete red herring, here. Turbulence has nothing to do with
lift (other than causing stalls and complicating the analysis).

> Some of the lifting force is counterbalanced by the keel underwater keeping
> the boat upright.

Well...the center of mass of the entire boat levered, as it is, upwind of the
center of buoyancy, produces a moment that counteracts the moment of the
sail's lift.

> For instance, a sailboat is not powered by the wind pushing on the sail.

It kind of really is. It's just more complicated because analyzing fluids
requires that we analyze continua, and not just discrete particles. In the
end, though, sailboats sail because they exchange momentum with the atmosphere
and the water through distributed forces, or pressures.

~~~
joshuaheard
I appreciate your explanation. I'm a sailor, not a PhD in fluid mechanics. All
I know about the physics of sailing I learned in the first couple of chapters
in the book I cited, which I think my post succinctly summarizes.

So, if I understand you correctly, to put it into one sentence for my friends
at the club, air flows along the curved sail which, through pressure
differences or momentum, turns the direction of the wind, and the opposing
force of the turn causes lift?

My other question is, how does a symmetrical keel then cause lift? Thanks.

~~~
theothermkn
Any frustration that shows in my reply is not particular to you. It's just
that folk ideas about fluids insinuate themselves everywhere with sometimes
irritating confidence. (For example, the book you cite!)

You're right about the sail turning the flow. However, the "curve" of the sail
is not the only way to turn a flow. In the keel's case, it sees an angle of
attack to the flow, and this causes lift. Imagine, for a moment, that the boat
isn't heeled over, and we're looking down on the boat as it moves through the
water. The bow of the boat, when pointing, points a few degrees upwind of the
direction of travel of the boat relative to the water. We go back to the Kutta
condition to see that the flow has to turn to point directly off the trailing
edge of the keel and see that water is being "thrown" to leeward.

It's a little more complicated than that, even, for keels, especially for full
keels. They're still "throwing water," but they're solidly "low aspect ratio"
and finite wing effects dominate: Lower lift, higher drag, higher stall angle,
softer stalls, attached vortices, and so on. All sorts of fun. There are
reasons that race boats tend to have fin keels and daggerboards! :)

------
drblast
Cool, but it's odd that the sail rotates around its own center point. Probably
would be more realistic to have it rotate around a mast at the leading edge.

I'd also love to see centerboard or keel forces since that's what makes the
boat go forward.

~~~
alephnil
This makes it a square rigged boat, which is the traditional rig used by old
sailships, and most traditional sailboats. That rigtype makes it hard
(impossible really) to go up against the wind with a small angle, and this
simulation is quite realistic in that respect.

------
tomkarlo
This would be more compelling and educational if the controls mapped closer to
how the controls you have available on a traditional sailboat work: * Rudder
position controls rate of rotation, not absolute heading, and doesn't work if
you're not making way * Main sheet (sail control) just controls the maximum
amount the sail can deviate from the center of the boat, not its absolute
angle relative to the boat (and not which side of the centerline it is on.)

~~~
dzhiurgis
Education-wise I think would this can be quite useful to train for man
overboard situations.

~~~
tomkarlo
I have to disagree... in particular, the point of reference (absolute) is also
all wrong. It's not going to teach you much about how to react to a man-over.
There really isn't much substitute for actual drills at sea to simulate the
real stress, surprise and difficulty of a MO where you don't have time to
switch over to your engine. Anyone who is skippering (and most crew) should be
able to handle an MO properly.

------
Stately
More info here:
[http://en.wikipedia.org/wiki/Point_of_sail#Close_hauled](http://en.wikipedia.org/wiki/Point_of_sail#Close_hauled)

Thanks for making this. As a teenager I used to sail competitively and this
brings good memories. Sailing close hauled under decent wind was incredibly
fun.

~~~
imakesnowflakes
You are welcome and thanks for the link. Really glad that you liked it.. )

------
shurcooL
Very neat. I was able to confirm and visualize my intuition on how sailboats
work.

It reminds me of a car parking simulator [1] I made a while ago.

[1]
[https://dl.dropboxusercontent.com/u/8554242/dmitri/projects/...](https://dl.dropboxusercontent.com/u/8554242/dmitri/projects/CarSim/CarSim.html)

~~~
couchand
Oh, I was hoping for some crash effects!

------
millzlane
I think keyboard controls would make this easier to tack/navigate. Left and
right to rotate boat and up down for sail. I could see this being a cool
racing game with obstacles and changing wind direction. Thanks for sharing.

------
gus_massa
I need some time to figure it out, but the little blue dots are the "air
molecules". They bounce against the sail!

I first thought that they were the sea waves, of a nice visual effect, but
they are a part of the simulation.

~~~
imakesnowflakes
Yes, every time one of those hit the 'sail' the direction and magnitude of the
force it imparts on the sail is calculated. It is not really needed, as one
could just calculate it from the strength and direction of wind in relation to
the sail, and setting that they hit the sail at some constant rate. I decided
to render it so that it gives some intuition regarding the forces that are
acting on the sail.

~~~
alistairjcbrown
I like that it shows the air which has hit the sail and then spilled off, or
"dirty" air. It's a good indication of why you don't want to be sailing behind
a boat you are trying to catch!

------
jjallen
Thank you for illustrating my favorite fact about sailing: that the fastest
speed at which a sailboat can sail is actually upwind.

I learned this from an awesome book, no doubt one that many on HN have heard
of, Thinking Physics, by Lewis Carroll Epstein that is worth getting,
especially if you have kids and they don't already know basic physics.

~~~
codeduck
This depends entirely on the sail plan of the ship in question.

An AC-72 might be fastest upwind, but a square-rigged ship definitely isn't.

~~~
adrianpike
Even AC72s are fastest a ways off true because of how far forward it drags
your apparent angle.

------
symes
Very nice. You should give the boat a cat-rig like a laser to remove the mast
in the middle.

You may want to check out the guys at SailX. They are focusing on the
simulation of sailboat racing, but they needs some of the same principles that
you are trying to simulate. [http://www.sailx.com/](http://www.sailx.com/)

For instead of sail-power complete guide, take a look at Aero-Hydrodynamics
and the Performance of Sailing Yachts. This is a fun tech-read.
[http://www.amazon.com/gp/product/0071629106/ref=pd_lpo_sbs_d...](http://www.amazon.com/gp/product/0071629106/ref=pd_lpo_sbs_dp_ss_1?pf_rd_p=1944687562&pf_rd_s=lpo-
top-
stripe-1&pf_rd_t=201&pf_rd_i=1888671181&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=1W6NHC5W3JX6EN8NTN56)

To add to the discussion on sailing faster than the wind, I present Blackbird
- which was a land yacht made to sail faster than the wind....DDW! The final
design was able to sail 2x the speed of the wind.

[http://en.wikipedia.org/wiki/Blackbird_(land_yacht)](http://en.wikipedia.org/wiki/Blackbird_\(land_yacht\))

------
jacquesm
Nice one, I love little programs like this that teach visitors something.

~~~
imakesnowflakes
Thanks :)

------
demallien
Woah, a little trip down memory lane... This post made me think of this:
[http://www.mobygames.com/game/american-challenge-a-
sailing-s...](http://www.mobygames.com/game/american-challenge-a-sailing-
simulation)

This was actually quite a reasonable sailing simulator if I remember
correctly. Good enough that when I finally got a chance to sail for real a few
years later, I knew what I needed to be doing in terms of positioning sails to
obtain various points of sail. Of course, navigating without an overhead map
being available, and knowing about ropes were two things that I still had to
learn the old-fashioned way :)

------
matthieurouif
Nice mechanics. However, it seems that you only take the drift into account
where the physics behind sailing in these situation is the lift apply to the
sail (which behaves like a wind)

------
abecedarius
My solar-sailing sim is similarly simple:
[http://wry.me/t/gravity/gravity.html](http://wry.me/t/gravity/gravity.html)

------
adamtj
This seems wrong. The boat never moves when Sail Angle is 0. Boat Angles of 40
and 90 should cause motion with a Sail Angle of 0, but they don't.

~~~
imakesnowflakes
The idea is that, the boat will have a very large drag in the direction
perpendicular to the keel. When you have 0 sail angle, the force on the sail
is in a direction perpendicular to the direction that the boat is facing. So
the drag is very large and so it does not move. Only when the force on the
sail is at an slanting angle to the keel, the 'drag reduction' comes into play
and boat moves at a direction of least resistance. I know that it is not even
remotely accurate, as I think sailing involves a lot of complex forces. But it
is how I have modeled it and the reason why you are seeing this behavior.

------
bicx
Fun little sim, although a bit simplistic. Before I started sailing in real
life, I used this Android app to build an understanding of sailing physics
(which is quite difficult for some to understand until you see it):
[https://play.google.com/store/apps/details?id=com.mooncoder....](https://play.google.com/store/apps/details?id=com.mooncoder.sailor)

------
ay
Very nice!

A feature idea: would be cool to have a level with "increased
difficulty/realism" with just one degree of freedom - the sail. In real world
you can not turn the vessel on a whim. And the next level, make the wind
gusty, and make it a requirement to keep a certain speed to avoid "drowning",
and you have a rather fun windsurfing-simulator game :)

~~~
imakesnowflakes
>In real world you can not turn the vessel on a whim..

Yes. I originally planned to let the boat turn only using the rudder (the blue
line at the end of the boat). But after a while, I felt that it would make
very difficult to get it working.

------
dylanrw
Novel way to approach this problem. On projects in the past I just kept a
table of optimal angles (given the boat's performance characteristics) and
when there is significant overlap I adjusted the velocity. This approach does
a better job approximating wind though.

------
selmnoo
Absolutely awesome. Makes me want to look into real sailing. Sadly season for
sailing has pretty much ended -- will look into it next year then.

Thanks for sharing, would love to see any improvements toward making it more
realistic (as a teaching tool for sailing or something).

~~~
imakesnowflakes
Thankyou!

------
onion2k
Fun stuff. Could you add a numeric value for the green line? That way we could
see which setting get the best forward motion.

------
tehwalrus
took me quite a while to work out how to tack, with controls being so
different to an actual sailing boat (mast pivot at centre rather than leading
edge, and spinning the whole boat rather than the blue thing being the
rudder.)

However, I did manage to get a small resultant to the left, so woot! :)

------
bane
Sail: 200

Boat: 130

beating to windward while close hauled

wish I could see the keel forces

pretty cool!

------
3rd3
It's kind of counter-intuitive that it's possible to sail against the wind.

~~~
muyuu
Yep, that's why early sail designs used to be square and looked to maximise
sail area vs mast and boom (or frame).

Ships can advance into the wind because of:

\- drag reduction (hull shape, keep, rudder) : sideways force translates to a
diagonal forward movement

\- most importantly, lift: more than pushing the sail, the air pulls the sail
sliding from the outter side of it (which is why a lot of the cloth doesn't
actually suffer much forces in the middle of the sail which is what initial
intuition would tell - by far the most tension happens in the corners).

If push is stronger than lift, turbulence on the other side of the sail slows
down your boat rather than speeding it up. "Tell tales" stuck in strategic
points of the sails allow to quickly tell if the flow is correct, and
therefore the trimming is good. Boat speed, flapping and shape also show these
forces.

[http://i.imgur.com/hZlb34r.gif](http://i.imgur.com/hZlb34r.gif)

[http://i.imgur.com/uypQGJJ.jpg](http://i.imgur.com/uypQGJJ.jpg)

[http://i.imgur.com/5tJLUgF.jpg](http://i.imgur.com/5tJLUgF.jpg)

I don't think there's sail shape or lift in the simulation, but I suspect that
the drag is rather low or zero, which allows for some gains into the wind (but
real boats do better).

~~~
imakesnowflakes
>I don't think there's sail shape or lift in the simulation..

No. It is a very rough simulation (I am not sure if I can even call that). It
only takes into account the force of the wind 'hitting' on the sail and the
'drag reduction'.

I am not a physicist or have experience with sailing. I am just a freelance
programmer (currently out of work) from India, which means I even haven't seen
a real life sail boat. I made this using the stuff I got from Wikipedia and a
bit of intuition. So I guess it shows.

But I have a question regarding the boat traveling faster than the wind. Isn't
it due to the fact that the lift is a constant force, regardless of the speed
at which the boat is traveling? But a boat that is using the force of wind
hitting the sails, can only sail as fast as the wind, because at that point,
there is no wind hitting the sails.

~~~
adrianpike
No, the lift isn't constant. As your speed increases, assuming you're not
going dead downwind (very slow) so does your apparent wind speed.

[http://en.wikipedia.org/wiki/Sailing_faster_than_the_wind](http://en.wikipedia.org/wiki/Sailing_faster_than_the_wind)

------
ljk
> _green hexagon is the boat_

Isn't the boat a pentagon?

~~~
imakesnowflakes
Yes. it is now. It was a hexagon when I posted this. I changed it in response
to this comment

[https://news.ycombinator.com/item?id=8427491](https://news.ycombinator.com/item?id=8427491)

I have updated the page to read 'green polygon' now..)

------
adolph
That's sweet! Kinda hard to tack tho.

