Content
- The Camera Model
- Perspective Projection
- Orthographic Projection
Graphics 1 CMP-5010B
Dr. David Greenwood
February, 2022
From 3D to 2D…
To give a meaningful account of projection in graphics we have to move to 3D.
There are typically two types of projections we consider in graphics:
Extend the idea of homogeneous coordinates to 3D.
The perspective projection is a projection from 3D to 2D, so we need a 4 x 4 matrix to transform 3D points in homogeneous coordinates.
consider a horizontal cross section of the scene:
The relationship between the the 3D camera coordinate \(x_c\) and the 2D image coordinate \(x_i\) is:
\[\frac{x_i}{d} = \frac{x_c}{z_c}\]
\[\Rightarrow x_i = \frac{x_c}{\frac{z_c}{d}}\]
The relationship between the the 3D camera coordinate \(y_c\) and the 2D image coordinate \(y_i\) is:
\[\frac{y_i}{d} = \frac{y_c}{z_c}\]
\[\Rightarrow y_i = \frac{y_c}{\frac{z_c}{d}}\]
We first extend the 3x3 homogeneous matrix for 2D graphics to a 4x4 matrix for 3D graphics.
A perspective projection from 3D to 2D can then be expressed as:
\[ \begin{bmatrix} x \\ y \\ z \\ w \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 1 / d & 0 \end{bmatrix} \begin{bmatrix} x_c \\ y_c \\ z_c \\ 1 \end{bmatrix} \]
Let’s work out the matrix multiplication for each coordinate after projection:
\[ x = x_c ~, ~ y = y_c ~, ~ z = z_c ~, ~ w = \frac{z_c}{d} \]
To find the corresponding image coordinates, we divide:
\[ x_i = \frac{x}{w} = \frac{x_c}{\frac{z_c}{d}} ~, y_i = \frac{y}{w} = \frac{y_c}{\frac{z_c}{d}} ~, z_i = \frac{z}{w} = \frac{z_c}{\frac{z_c}{d}} = d, \]
so all \(z_i\) are equal to \(d\).
\[ \begin{bmatrix} x \\ y \\ z \\ w \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 1 / d & 0 \end{bmatrix} \begin{bmatrix} x_c \\ y_c \\ z_c \\ 1 \end{bmatrix} \]
parallel projection…
Orthographic projection projects a 3D object to a 2D plane using parallel projection lines, perpendicular to the image plane.
Parallel projection lines do not converge to a fixed camera point.
\[ \begin{bmatrix} x \\ y \\ z \\ w \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x_c \\ y_c \\ z_c \\ 1 \end{bmatrix} \]
Reading: