Projections

Graphics 1 CMP-5010B

Dr. David Greenwood

February, 2022

Content

  • The Camera Model
  • Perspective Projection
  • Orthographic Projection

Projection

From 3D to 2D…

Projection

To give a meaningful account of projection in graphics we have to move to 3D.

  • Projection from 3D results in a 2D image.

Projection

There are typically two types of projections we consider in graphics:

  • Perspective projection
  • Orthographic projection

Camera Model

Camera Model: E. Angel, Interactive Computer Graphics

View Frustum

view frustum

View Frustum

projection on near plane

View Frustum

view frustum culling

View Frustum

frustum metrics

Perspective Projection

Extend the idea of homogeneous coordinates to 3D.

Perspective Projection

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:

x-section

The relationship between the the 3D camera coordinate \(x_c\) and the 2D image coordinate \(x_i\) is:

x-section

\[\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:

y-section

\[\frac{y_i}{d} = \frac{y_c}{z_c}\]

\[\Rightarrow y_i = \frac{y_c}{\frac{z_c}{d}}\]

Perspective Projection

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} \]

  • However, these are homogenous coordinates, i.e. they are scaled by a factor of w.
  • take note that \(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\).

Perspective Projection

\[ \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} \]

Orthographic Projection

parallel projection…

Orthographic Projection

Orthographic projection projects a 3D object to a 2D plane using parallel projection lines, perpendicular to the image plane.

Orthographic Projection

Parallel projection lines do not converge to a fixed camera point.

Orthographic Projection

orthographic projection

Orthographic Projection

\[ \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} \]

Summary

  • The Camera Model
  • Perspective Projection
  • Orthographic Projection

Reading:

  • Hearn, D. et al. (2004). Computer Graphics with OpenGL.
  • Strang, Gilbert, et al. (1993) Introduction to linear algebra.
// reveal.js plugins