Chapter 03

Multiple Coordinate Spaces

World space, object space, camera space, and the basis vectors that connect them.

In this chapter

  1. Coordinate Spaces in Games
  2. Basis Vectors
  3. Span and Rank
  4. Linear Dependence & Independence
  5. Orthogonal & Orthonormal Bases
  6. Exercises
1

Coordinate Spaces in Games

A coordinate space is defined by an origin and a set of axes. Every coordinate space must be defined relative to some other coordinate space. The full pipeline in a real-time 3D engine is:

Object Space → World Space → Camera Space → Clip Space → Screen Space

The Key Spaces

A coordinate space is specified by its origin and axes. The origin defines position; the axes define orientation. Both must be described relative to some parent space.


2

Basis Vectors

The axes of a coordinate space are called basis vectors. Any vector in a space can be expressed as a linear combination of the basis vectors:

v = vx·p + vy·q + vz·r

Where p, q, r are the basis vectors and vx, vy, vz are the coordinates of v in that basis.

Converting Between Spaces

To convert a point from object space to world space, you need:

w = o + bx·p + by·q + bz·r

In matrix form, p, q, r become the rows (or columns, depending on convention) of a transformation matrix. This is exactly what the model matrix does in a vertex shader.


3

Span and Rank

The span of a set of basis vectors is the set of all vectors that can be expressed as linear combinations of those basis vectors — in other words, every point that can be reached by moving along those axes.

The rank of a basis is the number of dimensions in its span:

Full rank means the number of dimensions in the span equals the number of basis vectors. For a 3D game coordinate space, you need full rank (rank 3) — otherwise some directions cannot be represented.


4

Linear Dependence & Independence

If a basis vector lies within the span of the other basis vectors, the vectors are linearly dependent. Consequences:

If no basis vector can be expressed as a linear combination of the others, they are linearly independent. A proper 3D coordinate space requires three linearly independent axes.

A degenerate (non-full-rank) transformation matrix is non-invertible. In games this can happen when a scale transformation includes a zero component, or when a cross product is taken of two parallel vectors. Always check for this before inverting matrices used in lighting (e.g. the normal matrix).

5

Orthogonal & Orthonormal Bases

Orthogonal Basis

All basis vectors are mutually perpendicular — the dot product of any two is zero:

p · q = 0 p · r = 0 q · r = 0

Orthonormal Basis

Orthogonal and all basis vectors are unit length. The standard world-space axes {i, j, k} = {(1,0,0), (0,1,0), (0,0,1)} form the canonical orthonormal basis.

Finding Coordinates in an Orthonormal Basis

When the basis is orthonormal, finding a vector's coordinates is just three dot products:

bx = u · p by = u · q bz = u · r

This is why orthonormal bases are so computationally convenient — no matrix inversion needed to go from world space coordinates to basis coordinates.

Use the dot product to test if two vectors are orthogonal: if a · b ≈ 0 (within floating-point epsilon), they are perpendicular. This also appears in Gram-Schmidt orthogonalization, used to "re-orthogonalize" a camera matrix that has drifted due to accumulated floating-point error.

6

Exercises

1. Linear Independence Check

Are the vectors (1, 0, 0), (0, 1, 0), and (1, 1, 0) linearly independent?

No. The third vector is (1,0,0) + (0,1,0) — it lies in the span of the first two. The rank of this set is only 2 (a plane), not 3. It cannot be used as a 3D coordinate basis.

2. Coordinate Space Conversion

An object's local axes in world space are p = (1,0,0), q = (0,0,-1), r = (0,1,0), and its origin is at o = (5, 0, 3). A vertex in object space is at b = (2, 1, 0). What is its world space position?

w = o + bx·p + by·q + bz·r = (5,0,3) + 2·(1,0,0) + 1·(0,0,-1) + 0·(0,1,0) = (7, 0, 2).

3. Orthonormal Basis Coordinates

Given orthonormal basis vectors p = (1,0,0), q = (0,1,0), r = (0,0,1) and world vector u = (3, -1, 2), find the coordinates of u in this basis.

bx = u·p = 3, by = u·q = -1, bz = u·r = 2. Trivial because this basis is the standard one.

Interview Question

Explain the difference between world space and object space. Give a practical example of when you'd work in each.

World space is the global frame — physics, lighting, and AI all typically operate here. Object space is local to a mesh — vertex positions in a .fbx file are in object space, which is why you need the model matrix to transform them into world space before rendering. Animations are often authored in object space relative to a skeleton's bind pose.

Interview Question

What is an orthonormal basis and why is it important for transformation matrices used in games?

An orthonormal basis has mutually perpendicular unit-length axes. Rotation matrices are orthonormal — this means their inverse equals their transpose (M⁻¹ = Mᵀ), making inversion trivially cheap. If a matrix's columns are not orthonormal (due to non-uniform scale or accumulated error), this fast-inversion trick no longer applies, and you need the costly general matrix inverse.
← Chapter 2 ↑ Index Chapter 4 →