Affine Transformations: Placing Things in the World
The artist drew the crate once, centred on its own little origin, with corners one unit from the middle. The level wants a big version of it, tipped on its side and sitting at on the quay. Getting from the drawing to the world takes a scale, a rotation and a slide, and the order you do them in matters.
The rule
Scale, rotate, then translate: write it T·R·S, read right to left.
An affine transformation is a linear transformation followed by a slide, called a translation: . A slide on its own isn't linear, because it moves the origin. The coordinate from the last lesson lets one 3×3 matrix do both at once:
For a point, and the slide is added. For a vector, and the slide vanishes. That's exactly what you want: moving a crate changes where its corners are, but not which way it faces.
The standard recipe is to scale first (about the object's own centre), then rotate (still about that centre), then translate it into place. Written as one product that is , and a point meets S first.
The shortcut
Read the finished matrix like a label. Its last column is where the object's local origin lands, which is its position in the world. Its first two columns are its x and y axes after scaling and rotating.
Scale by 2
The corner (1, 1) becomes (2, 2).
Now do the steps in the wrong order. Translate (1, 1) first, to (11, 4); rotate it, to (−4, 11); scale it, to (−8, 22). The crate has swung around the world origin and ended up far from the quay, 22 m up in the sky. Translating before rotating is the classic "my object orbits instead of spinning" bug.
Drills
Answer fast — trust the rule.
A crate's world matrix has rows (0, −2, 10), (2, 0, 3) and (0, 0, 1). Where is the crate's local origin in the world?
The drone's forward direction is (1, 0, 0). You apply a translation by (5, 2). What does the direction become?
A crate is first translated to (10, 3) and then rotated 90° counter-clockwise about the origin. Where does its centre end up?
In M = T · R · S, which transformation does a point meet first?
Remember
- Affine = linear, then a slide; a 3×3 matrix with a w coordinate does both at once.
- Scale, rotate, translate: M = T·R·S, applied right to left; the last column is the position.
- Points (w = 1) slide and directions (w = 0) don't. Translating first makes objects orbit the origin.
