Find correct 2D position of a point after rotation

155 Views Asked by At

Suppose there is a white rectangle $R$ with a red point $P$ drawn on it.

Suppose there is a camera looking at $R$.

  • $R$ center is in the position $(0,0)$ of the camera (its center)

  • $P$ is in position $(-x_0, -y_0)$ of the camera

Then $R$ is rotated by $N$ degrees in $x$ axis (where $0<N<90$).

  • $R$ center stays the same (in the world and in the camera)

  • $P$ is now in position $(-x,-y)$ of the camera

How can I find $x$ and $y$ (given I have all information that may be needed, such as distance $d$ from camera origin to $R$ center, $w$ and $h$ (width and height of $R$), etc.)?

enter image description here

1

There are 1 best solutions below

1
On BEST ANSWER

The projection equations are

$$\begin{cases}X=\dfrac{fx}{z+f}, \\Y=\dfrac{fy}{z+f}\end{cases}$$ where $f$ denotes the focal distance (distance of the observer to the origin).

If you apply a rotation of angle $\theta$,

$$\begin{cases}x'=x\cos\theta-z\sin\theta, \\y'=y, \\z'=x\sin\theta+z\cos\theta\end{cases}$$

and combining,

$$\begin{cases}X=\dfrac{f(x\cos\theta-z\sin\theta)}{x\sin\theta+z\cos\theta+f}, \\Y=\dfrac{fy}{x\sin\theta+z\cos\theta+f}.\end{cases}$$


If you very $\theta$, the trajectories are ellipses.