How to refactor this sailboat transform to solve for apparent wind direction for the sailboat plotting algorithm

calculusphysicsprogrammingtrigonometry

The core problem I would like assistance with is this:

How do I refactor this formula to transpose $a$?

$$\sin(a_0)\sin(a) \biggl(\frac{ \sin(\frac{a}{2})}{\sin(a_0 – a)}\biggr) ^2 = VW \cdot \eta$$

For more context, please read on.

I'm in a little over my head, and may be mixing up some terms, so please forgive my ignorance. I am attempting to write a route plotting algorithm that calculates a sailboat's $VMG$ (a measure of how optimal a sailboat's heading or direction of sail is) using live wind velocity and wind direction. The goal is to give the user a tool for optimizing pathfinding in the context of sailing. VMG is calculated using this formula:

$V$ = boat speed
$x$ = angle of wind relative to the front of the boat

$$VMG = V \cdot \cos(x)$$


In order to calculate boat speed from wind speed, I plan to use this formula, which is apparently widely accepted:

$VW$ = wind velocity
$a_0$ = true wind angle relative to the front of the boat
$a$ = apparent wind angle (i.e. wind generated by movement of the boat)

$$VB = VW \cdot \frac{\sin(a_0 – a)}{\sin(a)}$$

In order to solve this, I need to find $a$.


This article by Yoav Raz posits that a can be found by solving for it in his sailboat transform:

VW= wind velocity
$a_0$ = true wind angle relative to the front of the boat
$a$ = apparent wind angle (i.e. wind generated by movement of the boat)
$\eta$ = a complex measure of the boat's resistance to acceleration which for this purpose I will assume to be a low, constant number around 0.01)

$$\sin(a_0) * \sin(a) * \biggl(\frac{ \sin( \frac{a}{2})}{ sin(a_0 – a)}\biggr) ^2 = VW \cdot \eta$$

In practice, I will know the wind velocity and true wind angle, and as I said will be assuming $\eta$. Here is where the trouble starts: I am not very good at math anymore, and I find myself at a loss as to how to refactor this formula for my purposes. In order to use this formula in my algorithm, I need to refactor it into an expression that isolates $a$ given the other parameters( i.e. $a=f(x)$ ).

I've tried to refactor it by using trigonometric identities, which I think is the right path. The farthest I've gotten is this:

$$\sin(a_0) \sin(a) \biggl( \frac{\sin(\frac{a}{2})}{\sin(a_0)\cos(a)-\cos(a_0)\sin(a)}\biggr)^2 = VW\cdot \eta$$

I know I'm kind of asking "please teach me trigonometry and calculus," so my apologies for that. I'm just hoping that even if I'm barking up the wrong tree that someone can help point me in the right direction.

Edit:
It now occurs to me that the solution might be to simply iteratively attempt to solve this by trying inputs for a and attempting to solve for 1. The Raz article suggests doing this and starting with values slightly below a0. I could write a model to evaluate this expression with decreasing values until it arrives at a value a such that both sides resolve to 1.

Here are some more relevant resources to this problem space, if you would like to understand a bit more background around this topic:

The Physics of Sailing

Sailboat speed Vs. wind speed

Velocity Made Good

Polar Diagram

Apparent Wind Speed

Best Answer

Your equation is $$\sin(a_0) \, \sin(a) \, \biggl(\frac{ \sin( \frac{a}{2})}{ \sin(a_0 - a)}\biggr) ^2 = VW \, \eta$$ For personal conveniency, I shall change notations : $b=a_0$ , $k=VW\, \eta$ and I shall consider that we look for the zero of function $$f(a)=\sin ^2\left(\frac{a}{2}\right) \sin (a) \sin (b)-k \sin ^2(a-b)$$ For $a=b$, we have $$f(b)=\sin ^2\left(\frac{b}{2}\right) \sin ^2(b)$$ $$f'(b)=\sin ^2\left(\frac{b}{2}\right) \sin (b) (1+2 \cos (b))$$ $$f''(b)=\frac{1}{4} (2 \cos (b)+\cos (2 b)-2 \cos (3 b)-8 k-1)$$ $$f'''(b)=-\sin (b)-\frac{1}{4} \sin (2 b)+\sin (3 b)$$

Assuming that $a$ is close to $b$, let us make one single interation of Halley method to get $$a_{(1)}=b-\frac{2 f(b)\, f'(b)}{2 f'(b)^2-f(b)\, f''(b)}$$

Just to make a test, trying for $b=\frac \pi 6$ and $k=0.5$, the above would give $$a=\frac{\pi }{6}-\frac{30 \sqrt{3}-22}{277}\approx 0.415434 $$ while the "exact" solution is $0.399521$. In degrees, $b=30^{\circ}$ leads to an estimate of $a=23.8026^{\circ}$ while the "exact" solution is $a=22.8909^{\circ}$.

If, this is not sufficiently accurate, make one single interation of Householder method to get $$a_{(1)}=b+\frac{3 f(b) \left(f(b)\, f''(b)-2 f'(b)^2\right)}{f(b)^2 f'''(b)+6 f'(b)^3-6 f(b)\, f'(b)\, f''(b)}$$ For the worked example, this gives $$a=\frac{\pi }{6}-\frac{7209 \sqrt{3}-6846}{43739} \approx 0.394644 $$ corresponding to $22.6114^{\circ}$.