Specify any perspective transformation

115 Views Asked by At

I want to specify a perspective transformation using rotation angles. This should transform a homogeneous co-ordinate $q$ to another. Basically, a square would look like a trapezoid after the transformation.

$\begin{bmatrix}x'\\y'\\w'\end{bmatrix} = P\begin{bmatrix}x\\y\\1\end{bmatrix}$

This is what I have so far:

$ P = \begin{bmatrix}1 &0&0&0\\0&1&0&0\\0&0&1&0\end{bmatrix} R_x(\alpha)R_y(\beta)R_z(\gamma) \begin{bmatrix}1 &0&0\\0&1&0\\0&0&0\\0&0&1\end{bmatrix} $

What I do is first project $q$ onto the $z=0$ plane, then apply the appropriate rotation matrices in 3D. I then do another projection back to the 2D co-ordinate system, where $w'$ can specify the scaling of the $x'$ and $y'$. However, it looks like I'm missing something since I don't get the right transformation.

1

There are 1 best solutions below

0
On BEST ANSWER

Ok I realized my mistake. The correct formulation is:

$ P = \begin{bmatrix}1 &0&0&0\\0&1&0&0\\0&0&\frac{1}{d}&1\end{bmatrix} R_x(\alpha)R_y(\beta)R_z(\gamma) \begin{bmatrix}1 &0&0\\0&1&0\\0&0&0\\0&0&1\end{bmatrix} $

Where $d$ is the distance the projection plane of $q$ is from the camera.