Graphics › Start here
Transformations
Move it, spin it, resize it. Three operations — translate, rotate, scale — and the order you apply them in changes everything.
model matrix M = T · Ry · Rx · S
| 0.49 | 0.00 | 0.34 | 1.50 |
| 0.00 | 0.60 | 0.00 | 0.40 |
| -0.34 | 0.00 | 0.49 | 0.00 |
| 0.00 | 0.00 | 0.00 | 1.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 three moves
- Translate — slide by (tx, ty, tz). Doesn't change size or orientation.
- Rotate — turn around an axis by an angle. Doesn't change size or position of the centre.
- Scale — multiply along each axis. Uniform scale keeps the shape; non-uniform squashes it.
Each is a 4×4 matrix (translation needs the 4th row/column — that's why we use homogeneous coordinates). Combine them by multiplying.
Order matters — read right to left
M = T · R · S applied to a vertex v means T · (R · (S · v)): scale first, then rotate, then translate. Swap to S · R · T and you scale a thing that's already been moved away from the origin — it shoots off in a weird direction. The usual recipe is scale → rotate → translate.Why scale-rotate-translate, in that order?
Scaling and rotating both happen about the origin. So you do them while the model is still centred on the origin (model space), then translate it into place last. Translate first and your rotation becomes an orbit; scale first-then-translate is fine, but translate-then-scale stretches the offset too.
Inverse transforms
Every transform has an undo. The inverse of “translate by t” is “translate by −t”; of “rotate by θ” is “rotate by −θ”; of “scale by s” is “scale by 1/s”. The view matrix is exactly this: the inverse of the camera's own transform.