Find one side of a right triangle when you know part of the other side and two angles? Let's say a boat is anchored on the sea, with the angle $a$ between the surface and the anchor line. The boat then moves a distance $X$ towards the anchor point, whereby the angle changes to $b$. How can I from these known parameters calculate the depth of the anchor point? 
I did some juggling with $\tan$ and came up with
$$Y = \frac X{\tan(90-a) - \tan(90-b)}$$
Is this correct? 
I did some testing and it seemed to work out, but I'm not entirely sure that I'm testing it correctly. Was hoping somebody could confirm the formula or suggest a better one.
(I forgot the right angle marker in the top right corner of the figure!)


Let the dotted horizontal line have length $T$. Then we have $$\tan b=\frac YT\implies T=\frac Y{\tan b}$$ and $$\tan a=\frac Y{X-T}\implies X\tan a-\frac Y{\tan b}\tan a=Y$$ so $$Y=\frac{X\tan a}{1+\frac{\tan a}{\tan b}}=\frac{X\tan a\tan b}{\tan a+\tan b}$$
