Suppose you have an angle of degree theta painted on the ground at a spot. You are standing d distance away and looking at it from a height of h and from your perspective the angle appears to be of degree x. Is there a formula to calculate theta knowing d, h, and x?
Looking at an angle rotated
53 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 2 best solutions below
On
I'm going to assume that the perspective that you are interested in is the projection onto a flat surface, that is $$x' = x / z$$ $$y' = y / z$$
Using $x$ for right, $y$ for up, and $z$ for depth (this would be a left handed coordinate system, although most software uses a screwy right handed coordinate system). If you are interested in the mapping onto a convex surface or an orthographic projection, you would use a different perspective formula.
To characterize the measure of the angle, we'll use two 3D vectors $v_1$ and $v_2$ to be the "legs" of the angle. The corner of the angle will be coordinate $\omega$, and the viewer will be standing at the origin (that makes this much easier). You specified that $v_1$ and $v_2$ are in the ground plane, so we know that $v_{1,y} = 0$ and $v_{2,y} = 0$. You also specified the coordinate for $\omega$ as $[0, -h, d]$. First we know the angle between two unit vectors is given by the dot product formula:
$$\cos(\theta) = v_1 \circ v_2 = v_{1,x}v_{2,x} + v_{1,z}v_{2,z}\tag{T1}$$
If we were to find the 2d coordinates of the perspectives of $\omega + v_1$ and $\omega + v_2$ and $\omega$, and find the angle between them, that wouldn't actually give us the correct 2D angle. The is because perspectives bend straight lines. We actually need to see what the angle measures as the length of $v_1$ and $v_2$ becomes zero, to see what the measure is exactly at the base of the two vectors. So we'll generalize the length of $v_1$ and $v_2$ to be $r$, and find the 2D perspective coordinates:
$$ w_1 = \text{perspective}(\omega + v_1\,r) = \begin{bmatrix} \frac{(v_1\,r + \omega)_x}{(v_1\,r + \omega)_z}\\ \frac{(v_1\,r + \omega)_y}{(v_1\,r + \omega)_z} \end{bmatrix} = \begin{bmatrix} \frac{r\,v_{1,x} + \omega_x} {r\,v_{1,z} + \omega_z}\\ \frac{r\,v_{1,y} + \omega_y} {r\,v_{1,z} + \omega_z} \end{bmatrix} = \begin{bmatrix} \frac{r\,v_{1,x}} {r\,v_{1,z} + d} \\ \frac{-h} {r\,v_{1,z} + d} \end{bmatrix} \tag{T2}$$
$$ w_2 = \text{perspective}(\omega + v_2\,r) = \begin{bmatrix} \frac{(v_2\,r + \omega)_x}{(v_2\,r + \omega)_z}\\ \frac{(v_2\,r + \omega)_y}{(v_2\,r + \omega)_z} \end{bmatrix} = \begin{bmatrix} \frac{r\,v_{2,x} + \omega_x} {r\,v_{2,z} + \omega_z}\\ \frac{r\,v_{2,y} + \omega_y} {r\,v_{2,z} + \omega_z} \end{bmatrix} = \begin{bmatrix} \frac{r\,v_{2,x}} {r\,v_{2,z} + d} \\ \frac{-h} {r\,v_{2,z} + d} \end{bmatrix} \tag{T3}$$
$$\Omega = \text{perspective}(\omega) = \begin{bmatrix} \frac{\omega_x}{\omega_z}\\ \frac{\omega_y}{\omega_z} \end{bmatrix} = \begin{bmatrix} 0\\ \frac{-h}{d} \end{bmatrix}\tag{T4}$$
You specified $x$ is the perspective angle, so applying the dot product law angle law again, as close to the base of vectors as possible:
$$\cos(x) = \lim_{r \rightarrow 0} \frac{(w_1 - \Omega) \circ (w_2 - \Omega)}{|w_1 - \Omega| \cdot |w_2 - \Omega|} \tag{T5}$$
Putting (T2),(T3), and (T4) into (T5), and summarizing, we get:
$$\cos(x) = \frac{h^2\,v_{1,z}\,v_{2,z} + d^2\,v_{1,x}\,v_{2,x}}{\sqrt{(h^2\,v_{1,z}^2 + d^2\,v_{1,x}^2)(h^2\,v_{2,z}^2 + d^2\,v_{2,x}^2)}} \tag{T6}$$
Now your question is reduced to finding $\cos(\theta)$ in terms of $\cos(x)$, keeping in mind that the $v$s are unit vectors, that is (probably should have written this at the beginning): $$v_{1,x}^2 + v_{1,z}^2 = 1 \tag{T7}$$ $$v_{2,x}^2 + v_{2,z}^2 = 1 \tag{T8}$$
Among (T1), (T6), (T7), and (T8) we have four free variables, $v_{*,*}$, and four equations, so the 3D angle is fully determined by the 2D angle. However, it won't be anything elegant unless you make additional assumptions. The following assumptions aren't necessary but either of them would make the final form more gentle on the eyes:
- $h = d$, which results in $\cos(\theta) = \cos(x)$, very nice.
- A line from the viewer to $\omega$ bisects the angle, which gives $v_{1,x} = -v_{2,x}$ and $v_{1,z} = v_{2,x}$, and the relation between the angles simplifies to $$\cos(\theta) = \frac{(\cos(x) + 1)d^2 + (\cos(x) - 1)h^2}{(\cos(x) + 1)d^2 - (\cos(x) - 1)h^2} \tag{Final}$$
Your description is still confusing. I’m going to answer the question that I think you meant, and with only a little effort, you should be able to modify it to apply to your situation, whatever that is. For me, the usual way to arrange the axes is to make the $xy$-plane the floor, and have the $z$-axis pointing upwards. You say that you want an angle painted on the floor, i.e. within the $xy$-plane, and with vertex at the origin. And you are observing it from a point above the floor, and directly above the $x$-axis. Knowing the location of your eye and the position and magnitude of your angle, there is indeed a relationship between the angle as drawn and what your eye sees in perspective.
This is a “simple” problem, but takes a bit of work nonetheless. I’ll take a very general angle drawn in the $xy$-plane, and for convenience I’ll draw the end-points on the unit circle. So one side of the angle will run from the origin to $P=(x,y)$ where $x^2+y^2=1$, and the other will run from the origin to $P'=(x',y')$. Your $\theta$ has the property that its cosine is $xx'+yy'$; you can get this from the dot-product of the two vectors, or the fact that $\cos(\alpha-\beta)=\cos\alpha\cos\beta+\sin\alpha\sin\beta$.
Now your eye-point $E$: I place that above the $x$-axis, so that its $y$-coordinate is zero, it’ll have the coordinates $(d,0,h)$: you’re looking from a height of $h$ and standing a distance of $d$ from the origin.
What do you want? You want the angle between two planes, the plane $EOP$ and the plane $EOP'$. In the jargon, this is called a dihedral angle. A moment’s thought persuades you that this angle is the same as the angle between the two normal vectors to the planes, and we can calculate this too. You get the normal vector by a cross-product, $\overline{OP}\times\overline{OE}$, similarly $\overline{OP'}\times\overline{OE}$. The first cross-product is $(yh,-xh,-yd)$, this is a normal vector $N$ to the first plane, but this won’t be a unit vector, its magnitude is $\|N\|=(y^2h^2+x^2h^2+y^2d^2)^{1/2}=(h^2+y^2d^2)^{1/2}$, using the fact that $x^2+y^2=1$. The other calculations are exactly the same, with primes stuck on in the appropriate places. Now to get the angle between $N$ and $N'$, you just use the fact that the cosine of the angle between them is $N\cdot N'$ divided by $\|N\|\|N'\|$. This is the cosine of the perspective-seen angle, don’t forget.
If your strategy is that you’re observing the perspective angle and want to know the size of the original angle, you have to work backwards, and this may be fairly hard, but don’t forget that then you’ll need to know the exact placement of one of the sides of the original, as you did specify in your original statement.