Calculating angle to object based on height dimensions Given $h_1$ and $h_2$ (left and right height of a square respectively at a certain perspective), how can we calculate the angle relative to a square from that perspective?
See the following diagrams for clarification:

^^^ this is the view of the square from that perspective

^^^ this is a top view showing the angle we are trying to calculate
This is a rather complex task - it's difficult for me to approach it. Is it possible by getting a predetermined angle & ratio of $h_1$ and $h_2$ and using similarities?
Note: not sure if it will help but $h_1$ and $h_2$ are both numerical values (pixels)
 A: Let the eye of the viewer be at $(0, 0, e)$
Let the square have side $a$ and its center be at $(0, 0, -d)$
Let the projection plane be the $xy$ plane, and the plane of the square have a unit normal vector of $N = (\sin t, 0, \cos t)$.  Spanning vectors of the plane of the square are: $(\cos t, 0, -\sin t)$  and $(0, 1, 0)$.

Top Corners of the square:
Top Left corner at: $(0, 0, -d) + (a/2) ( - \cos t, 1, \sin t )$
Top Right corner at: $(0, 0, -d) + (a/2) ( \cos t , 1, -\sin t )$

Ray from eye to top left corner is:
$r = (0, 0, e) + s ( (0, 0, -d - e) + (a/2) ( - \cos t, 1, \sin t ) )$
at $z = 0$:
$s = \dfrac{- e}{  - d - e + (a/2) \sin t } = \dfrac{e}{d + e - (a/2) \sin t} $
In the image, the top left corner has coordinates $(x_1, y_1)$ with
$x_1 = - \dfrac{(ae/2) \cos t}{  d + e - (a/2) \sin t }$
$y_1 = \dfrac{a e/2 } {d + e  - (a/2) \sin t }$
Similarly, in the image, the top right corner has coordinates $(x_2, y_2)$ with
$x_2 = \dfrac{a e / 2 \cos t}{  d + e + (a/2) \sin t }$
$y_2 = \dfrac{a e / 2}{ d + e + (a/2) \sin t }$
If follows that
$- x_1 / y_1 =  \cos t  =  x_2 / y_2 $
Hence,
$x_1 = -\cos t \ y_1$
$x_2 = \cos t \ y_2$
The horizontal width of the image (the distance between the two vertical lines) is
$ W = x_2 - x_1 = \cos t (y_2 + y_1 ) $
But $y_1 = \dfrac{h_1}{2} $ and $y_2 = \dfrac{h_2}{2} $
Hence,
$\cos t = \dfrac{ W }{\overline{h}}$
where $\overline{h} = \dfrac{1}{2} ( h_1 + h_2 ) $
