Math Playground
Back to Graphics

Graphics › Start here

Matrices & the MVP

One 4×4 matrix per coordinate space. Multiply Model, View and Projection together and a single matrix carries any vertex from the mesh file to clip space.

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).

A matrix is a change of coordinates

Every 4×4 transform matrix says “here's where the x-axis goes, here's where y goes, z goes, and here's the new origin” — those are its four columns. Multiply a vertex by it and you've re-expressed the vertex in the new space.

The MVP chain

  • M — model matrix: model space → world space. Poses the object.
  • V — view matrix: world space → view space. The inverse of the camera's pose.
  • P — projection matrix: view space → clip space. Then the GPU does ÷w to land in NDC.

Combine: clip = P · V · M · vertex. Engines often pre-multiply MVP = P · V · M once per object per frame and hand the GPU just that.

Why right-to-left?

The vertex is on the right, so the matrix nearest it acts first: P·(V·(M·v)) — model, then view, then projection. If you ever see things “inside the camera” or rotating the wrong way, check the multiplication order before anything else. (Also check row-major vs column-major — APIs disagree, and a transpose hides in there.)

Order, associativity, and one more thing matrices can't do

Matrix multiplication is associative — you can group the chain however you like — but not commutative: A·B ≠ B·A in general (rotate-then-translate ≠ translate-then-rotate). And a single matrix can do scale + rotate + translate + perspective in one shot — but it can't do a bend or a twist; non-linear deformations need a different tool (skinning, displacement, shaders).