Find a distance based on height and angles towards base and top of an object? Suppose I know the vertical height of an object and the angles (in relation to horizontal) towards the top and bottom of it. Is it possible to calculate the horizontal distance to the object based on this information?
In the image below, the height of the object is y, the horizontal distance is x and the angles between horizontal and the top/bottom of the object are a and b. The knowns are y, a and b, and I want to find x.

Is this even possible to do exactly, or do I need to make some kind of estimation (I'm gonna implement this in software).
 A: Going by the figure you've drawn leftmost , 

If you split the total $y$ into $y_1$ and $y-y_1$ you can proceed ahead as ,
In the upper triangle , you can write $\tan(\alpha)=\frac{y_1}{x} \cdots (1)$
similarly for the lower triangle you can write $\tan(\beta)=\frac{y-y_1}{x} \cdots (2)$
Now putting $$x=\frac{y_1}{\tan(\alpha)}\cdots(3)$$ in $(2),$
You get $$\tan(\beta)=\frac{y-y_1}{y_1}\cdot\tan(\alpha)$$
Or  $$\tan(\beta)=\left(\frac{y}{y_1}\right)-1\cdot\tan(\alpha)$$
Or $$\frac{\tan(\beta)}{tan(\alpha)}+1=\left(\frac{y}{y_1}\right)$$
Or $$y_1=\frac{\tan(\alpha)\cdot y}{\tan(\alpha)+\tan(\beta)}\cdots (4)$$
Putting $(4)$ back in $(3)$ you finally get , $$x=\frac{y}{\tan(\alpha)+\tan(\beta)}$$  , which is the required distance horizontal distance to the tower .
A: For the first case let consider
$$y=y_a+y_b$$
then by trigonometric relation for right triangle
$$y_a=x\tan a \quad y_b=x\tan b\implies y=y_a+y_b=x(\tan a+\tan b) \implies x= \frac{y}{\tan a + \tan b}$$
By the same kind of argument, for the second and third cases, which are equivalent, note that
$$y=x\tan(a+b)-x\tan a\implies x= \frac{y}{\tan (a+b) - \tan a}$$

