Math Playground
Back to Graphics

Graphics › Coordinate spaces

Coordinate systems

The same point has a different address in every space it passes through. Step the cube through all five and watch its coordinates change.

Coordinate spaces — follow a cube from mesh to pixels
xyz

Model space: the cube as the mesh file stores it — built around its own origin, no idea where it'll end up.

the cube's far-top-right corner here: (0.5, 0.5, 0.5)

One vertex, five addresses

A “coordinate system” (or space) is just an origin and a set of axes. The vertex never moves — but as you change which origin and axes you measure from, the numbers change. Here's the journey, and the matrix that does each hop:

SpaceOrigin / axesThe matrix
Modelthe model's own centre— (it's where you start)
Worldthe scene's shared originModel matrix (scale · rotate · translate)
Viewthe camera, looking down −ZView matrix (the inverse of the camera's pose)
Clipthe canonical view volumeProjection matrix
NDCthe cube −1…1 in x, y, z÷ w (the perspective divide)
Screenpixels, (0,0) top-left, y downViewport transform

Left-handed or right-handed?

A space is right-handed if x→y→z follows your right hand's thumb/index/middle. OpenGL's view space is right-handed (camera looks down −Z); Direct3D's is left-handed (down +Z). Same idea, opposite sign — a classic source of “why is my model inside-out?” bugs.

Why bother with so many?

Each space makes one job easy. Lighting maths is cleanest in world (or view) space. Clipping is trivial once everything is “inside the cube or not”. Rasterizing wants pixels. Rather than special-case everything, graphics moves the data to wherever the next step is simplest — by multiplying by one more matrix.