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).


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}$$