I have this following question to answer, however I am not sure how I should combine my calculation into one final answer.
Suppose the Centre of Projection in a viewing space is at an offset
$(0, 0, -5)$ from $(0,0,0)$, and the view plane is the $UV$ plane containing
$c$. Find the transform matrix for the perspective projection, and give
the projected Word Coordinate point $(10,-20,-10)$ on the view plane.
So this is the transformation matrix: with $1/d=0.2$. ($1/5$)
$$
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 0 \\
0 & 0 & 1/d & 1
\end{pmatrix}
$$
Because the view plane is placed at $z=0$ we use the following similar triangles:
$$
x' = x/(z/d+1), \quad
y' = y/(z/d+1), \quad
z'=z/(z/d+1), \quad
w=z/d
$$
My question is, what values do I use for the $x$,$y$,$z$. If using the project world coordinates $x'$, $y'$, $z'$ will be undefined due to the $0$. Once I have the values for $x'$, $y'$, $z'$ do I multiple them by the transformation matrix?
Thanks for any help
Best Answer
We want to map $P = (x,y,z)^\top$ to $P'=(x',y',z')^\top$.
All rays go through $C = (0,0,-5)^\top = (0,0,-d)^\top$ and hit the plane $z = 0$.
(Large version here and here)
We have the line with intersection $$ (0,0,-d)^\top + t ((x, y, z)^\top - (0,0,-d)^\top) = (x', y', 0)^\top \iff \\ (tx,ty,t(z+d) - d)^\top = (x', y', 0)^\top $$
so we need $$ t(z+d) -d = 0 \iff t = d/(z+d) $$ This leads to \begin{align} P' &= (x', y', z')^\top \\ &= (x', y', 0)^\top \\ &= \left( \frac{d}{z + d} x, \frac{d}{z + d} y, \frac{d}{z + d} (z+d) - d \right)^\top \\ &= \left( \frac{d}{z + d} x, \frac{d}{z + d} y, 0 \right)^\top \quad (*) \end{align}
So far we are in agreement regarding $x'$ and $y'$. We have difference in $z'$, which should be $$ z' = \frac{1}{z/d + 1} (z+d) - d = \frac{d}{z + d} (z+d) - d = 0 $$ and $w'$ will be different as well, see below.
Using homogeneous coordinates we can write the transformation $(*)$ as $$ p' = T p \iff \\ \begin{pmatrix} x' \\ y' \\ z' \\ w' \end{pmatrix} = \begin{pmatrix} d & 0 & 0 & 0 \\ 0 & d & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & d \end{pmatrix} \begin{pmatrix} x \\ y \\ z \\ 1 \end{pmatrix} \quad (**) $$ we get a homogeneous image vector $$ p' = \left( d x, d y, 0, z + d \right)^\top $$ which can be normalized to $$ p' = \left( \frac{d}{z + d} x, \frac{d}{z + d} y, 0, 1 \right)^\top $$
Finally one can apply the above transformation $(**)$ to $p = ( 10, -20, -10, 1)^\top$.
This gives $p' = (50, -100, 0, -5)^\top$ which normalizes to $p' = (-10, 20, 0, 1)^\top$ or $P'=(-10,20,0)^\top$, where the $x'$ value agrees with the 2D image view shown above.