Solution (source code)

= Solution

Represent a <point> by the column of <homogeneous coordinates> $(X,Y,Z,1)^T$. The actions of the four <matrices> are:

|| Matrix
|| Geometric action and parameters

| $G(\theta)$
| A <proper rotation> about the $x$-axis: $(X,Y,Z)\mapsto(X,Y\cos\theta-Z\sin\theta,Y\sin\theta+Z\cos\theta)$. The angle $\theta$ is in <radians>, with the usual right-hand sense.

| $H(x,y,z)$
| A <translation> by $(x,y,z)$: $(X,Y,Z)\mapsto(X+x,Y+y,Z+z)$.

| $J(\lambda)$
| Uniform scaling by $\lambda$: $(X,Y,Z)\mapsto(\lambda X,\lambda Y,\lambda Z)$. Positive $\lambda$ gives a <uniform dilation>; $\lambda=0$ collapses the object to the origin; negative $\lambda$ additionally reverses its direction through the origin.

| $K(f)$
| <Perspective projection> from the origin onto the plane $Z=f$, where $f\ne0$ is the <focal length> in the chosen coordinate units.

The last operation produces $(X,Y,Z,Z/f)^T$. It requires a <perspective divide>: divide the first three components by the last. For $Z\ne0$,
$$
\boxed{K(f):\quad (X,Y,Z)\longmapsto\left(\frac{fX}{Z},\frac{fY}{Z},f\right).}
$$
This is why the last component of <homogeneous coordinates> cannot simply be discarded. <Points> with $Z=0$ have no finite projected position, and a visible scene normally uses $Z>0$ under this forward-axis convention. The first three transformations leave the last component equal to one and need no nontrivial divide. The displayed $K$ retains no depth variation after division; it describes projection onto the image plane, rather than a complete depth-buffer mapping.