up to Schedule & Notes

Projection Transformations

A fundamental operation in computer graphics is projection, which takes a 3D point and transforms it to the correct position on a 2D screen.

Below, $p$ is the 3D point in the world, $p'$ is the corresponding point on the screen, and $e$ is the eye toward which $p$ is projected. Note that $p'$ is also a 3D point because the screen is located in the 3D world.

How is $p'$ computed? Below is a 2D vertical slice through the line between $e$ and $p$. $u$ points vertically upward. $v$ points horizontally to the screen. The screen is perpendicular to $v$ and at distance $d$ from $e$.

The $u$ and $v$ vectors are perpendicular and unit length, so they form a coordinate system with its origin at the eye, $e$.

In the eye's $\langle u,v \rangle$ coordinate system, $p'$ has coordinates $(p'_u, p'_v)$ and $p$ has coordinates $(p_u, p_v)$.

Note that $p_u = (p-e) \cdot u$ and $p_v = (p-e) \cdot v$.

Note also that $p'_v$ is equal to the distance, $d$, from the eye to the screen.

So only $p'_u$ is unknown. By similar triangles,

$\large {p'_u \over p'_v} = {p_u \over p_v}$

So

$p'_u = {\large d \; p_u \over \large p_v}$

Homogeneous projection transformation

We can compute $(p'_u,p'_v)$ from $(p_u,p_v)$ with a homogeneous transformation:

$\begin{array}{cccl} (p_u,p_v) & \longrightarrow & ( p_u, p_v, 1) \\ & & {\Big\downarrow} \textrm{?} \\ (a/c, b/c) & \longleftarrow & (a, b, c ) \\ = ( {d \; p_u \over p_v}, d ) \end{array}$

What are $a, b, c$ to get the right answer, $( {d \; p_u \over p_v}, d )$ ?

${\large a \over \large c} = {\large d \; p_u \over \large p_v} \qquad \textrm{and} \qquad {\large b \over \large c} = d$

We can arbitrarily choose $c = p_v$. Then $a = d \; p_u$ and $b = d \; c = d \; p_v$.

As a homogeneous transform, this is

$\begin{bmatrix} a \\ b \\ c \end{bmatrix} = \begin{bmatrix} d \; p_u \\ d \; p_v \\ p_v \end{bmatrix} = \begin{bmatrix} d & 0 & 0 \\ 0 & d & 0 \\ 0 & 1 & 0 \end{bmatrix} \; \begin{bmatrix} p_u \\ p_v \\ 1 \end{bmatrix}$

Dividing by the last coordinate yields $(p'_u, p'_v) = ( {d \; p_u \over p_v}, d )$.

Note that we can use any scalar multiple of a homogeneous transformation matrix to acheive the same transformation, since the final division by the last coordinate has the effect of also dividing by the scalar multiple.

The more commonly used projection transformation multiplies the above transformation by ${1 \over d}$:

$\begin{bmatrix} p_u \\ p_v \\ {p_v \over d} \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & {1 \over d} & 0 \end{bmatrix} \; \begin{bmatrix} p_u \\ p_v \\ 1 \end{bmatrix}$

Again, dividing by the last coordinate yields $(p'_u, p'_v) = ( {d \; p_u \over p_v}, d )$.

In 3D, the homogeneous projection transform becomes

$\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & {1 \over d} & 0 \end{bmatrix}$
up to Schedule & Notes