# Simulate wind affecting a boat using a 2D physics engine like Box2D or SpriteKit?

I'm looking for a way to simulate the forces created by wind and how it affects a boat.

In a nutshell: if wind hits a boat (sailing yacht), the bow is aligning with the wind and if the wind is strong enough, the boat will then slowly start to move.

I am not looking for a correct simulation of sails or alike. Just wind as it would affect a boat during maneuvers at slow speed.

Here's what I have tried:

• Make the boat just one body and apply a force: this does not take into account the heavier stern versus the lighter bow.
• Make the stern a heavy body and the bow a lighter one and connect them with a fixed joint: this will make the boat rotate if the same force is applied to both bodies but ignores the fact that once the boat is aligned with the wind, the force should be reduced.
• Create many (thousands) of very small objects with little mass and apply a force to them, simulating the wind "particles" and let them hit the boat: this kills performance on slower devices.

Maybe I am missing a very simple solution that would work good enough?

• Have you thought of using the third solution, but instead of thousands of physics objects, using a smaller number? Greater mass and force, fewer number. Commented May 15, 2018 at 11:35

I think you can make this very simple by using the difference in angle between the boat and the wind direction.

Lets say the wind is going from the west (left) to the east (right) we can represent this as a vector(1,0)

Vector2 wind = Vector2(1,0);


Now, our boat direction can also be represented as a vector. lets say its facing north(up) that would equate to vector(0,1)

Vector2 boatDirection = Vector2(0,1);


We can now use the Vector2 method angle to get the difference between these 2 angles in a range -180 to 180.

float angleDifference = wind.angle(boat);


If we now turn this to an absolute value(0 to 180) and then - 90 this will give us a range of -90 to 90. 0 being sideways to the boat and -90 and 90 being full on front/back. We can then further reduce this to a 0-1 range by dividing by 90.

float appliedWindStrength = (Math.abs(Math.abs(angleDifference)-90) / 90f);


Now we have the strength multiplier we can use to modify the forces applied on the boat.

Using this 0-1 range we can then couple it with the smaller lighter stern and larger heavier aft.

stern.applyForce(x*appliedWindStrength);
aft.applyForce(x*appliedWindStrength);


I haven't had a chance to test this myself yet. Will update when I get the time.