Skip to content
Part IA Michaelmas Term

View Matrix and Look-At

Purpose

The view matrix transforms world coordinates to camera coordinates:

  • Camera at origin
  • Looking down z-z axis
  • +y+y up, +x+x right

Standard Camera Assumptions

For uniform projection mathematics:

  • Camera at origin (0,0,0)(0, 0, 0)
  • Screen centre at (0,0,d)(0, 0, -d)
  • Screen parallel to xyxy-plane

Look-At Construction

Given:

  • Camera position c\mathbf{c}
  • Look-at point l\mathbf{l} (where camera points)
  • Up direction u\mathbf{u} (which way is “up”)

Build Orthonormal Basis

  1. Forward: v^=clcl\hat{\mathbf{v}} = \frac{\mathbf{c} - \mathbf{l}}{|\mathbf{c} - \mathbf{l}|}

  2. Right: r^=u×v^u×v^\hat{\mathbf{r}} = \frac{\mathbf{u} \times \hat{\mathbf{v}}}{|\mathbf{u} \times \hat{\mathbf{v}}|}

  3. True up: u^=v^×r^\hat{\mathbf{u}} = \hat{\mathbf{v}} \times \hat{\mathbf{r}}

View Matrix

V=[r^xr^yr^zcr^u^xu^yu^zcu^v^xv^yv^zcv^0001]\mathbf{V} = \begin{bmatrix} \hat{r}_x & \hat{r}_y & \hat{r}_z & -\mathbf{c} \cdot \hat{\mathbf{r}} \\ \hat{u}_x & \hat{u}_y & \hat{u}_z & -\mathbf{c} \cdot \hat{\mathbf{u}} \\ \hat{v}_x & \hat{v}_y & \hat{v}_z & -\mathbf{c} \cdot \hat{\mathbf{v}} \\ 0 & 0 & 0 & 1 \end{bmatrix}

Look-at construction showing camera position, look-at point, up vector, and resulting basis vectors

Coordinate System Conventions

SpaceHandednessz-axis
Camera (OpenGL)Right-handedLook down z-z
NDCLeft-handed+z+z into screen

The projection matrix flips the handedness.

Summary

  • View matrix places camera at origin, looking down z-z
  • Constructed from position, look-at point, and up vector
  • Build orthonormal basis using cross products
  • Translation to origin + rotation to align axes

Past Paper Questions

2024 Paper 3 Question 4(b): Derive the look-at view matrix for a camera at position c\mathbf{c}, looking at point l\mathbf{l}, with up vector u\mathbf{u}.