Linear Transformations: Scale and Rotate
When the drone clips a gull, it tumbles through the air. Each frame of that tumble turns the sprite a little further, and each turn is a matrix. That sounds like a formula to memorise, but there's a way to build any such matrix from scratch in seconds: watch where two small arrows go.
The rule
A matrix's columns are where the x and y arrows land.
Multiply any matrix by and out comes its first column; multiply by and out comes its second. Every other vector is a mix of those two, so knowing where they land tells you everything. A transformation that works like this is linear: it keeps the origin fixed, keeps straight lines straight, and keeps evenly spaced grid lines evenly spaced.
Scale. Stretch x by and y by : lands on and on , so the matrix is . The landing squash from the last lesson is one of these.
Rotate by an angle , counter-clockwise. The x arrow swings to and the y arrow to , so
For a quarter-turn, 90°, that is , which sends to .
Combine two transformations by multiplying their matrices. "First A, then B" is the product , read right to left, because the vector meets A first. The order matters. Stretch x by 2 and then turn 90°: . Turn first and then stretch x: . Two different answers.
The shortcut
Don't memorise matrices — build them. Ask where lands and write it down as the first column; ask where lands and write it as the second.
Where does the x arrow go?
Turning (1, 0) a quarter-turn counter-clockwise points it straight up: (0, 1). That's the first column.
The trap is writing where the arrows land as rows instead of columns. For a rotation that quietly gives you the rotation the other way round.
Drills
Answer fast — trust the rule.
A transformation sends (1, 0) to (3, 0) and (0, 1) to (0, 2). Which matrix is it?
Rotate (0, 3) by 90° counter-clockwise. Where does it land?
Rotate (4, 0) by 30° counter-clockwise. Where does it land?
Stretch x by 2, then rotate 90° counter-clockwise. Where does (1, 0) end up?
Which of these is NOT a linear transformation?
Remember
- A matrix's columns are where (1, 0) and (0, 1) land.
- Rotation by θ has columns (cos θ, sin θ) and (−sin θ, cos θ); a quarter-turn sends (x, y) to (−y, x).
- "First A, then B" is BA: order matters, and writing rows for columns reverses a rotation.
