Math Playground
Back to Graphics

Graphics › Coordinate spaces

World space

The scene's shared coordinate system. The model matrix takes each object out of its own little world and plants it here — positioned, rotated and scaled.

3D transform — scale, rotate, translate a cube
xyz

model matrix M = T · Ry · Rx · S

0.490.000.341.50
0.000.600.000.40
-0.340.000.490.00
0.000.000.001.00

The dashed cube is the original; the solid one is M applied to it. Order matters — scale then rotate then translate is the usual recipe (read the matrices right-to-left).

The stage everything stands on

World space has one origin and one set of axes for the whole scene — metres from the centre of the level, say. Every object gets a model matrix M that maps its model-space vertices into world space: p_world = M · p_model. Change M and the object moves, turns, or resizes; the mesh data never changes.

The recipe

M = T · R · Sscale the model, then rotate it, then translate it into position. Read right-to-left because the vertex sits on the right.

Hierarchies: a model matrix made of model matrices

A character's hand should follow its forearm, which follows the upper arm, which follows the torso. So each part's world matrix is its local matrix times its parent's world matrix: M_hand_world = M_torso · M_upperarm · M_forearm · M_hand_local. This is a scene graph — move the torso and the whole arm comes along, for free.

Why lighting often happens here

Lights, the sky, gravity, physics — they're all defined in world space, so it's a natural place to do lighting and collision maths. (Some engines do lighting in view spaceinstead; same physics, just a different — and equally valid — frame to measure from.)