Foundations T1 / 27 · From High School
The Matrix Is a Ledger for Rotation
You already know that the derivative of f(x) = x² is 2x — and that sin(a+b) and cos(a+b) exist. Arrange them into a 2×2 table and you get the thing that appears ten thousand times in robotics: the rotation matrix.
One-line takeaway
The rotation matrix is not a new invention; it is a bookkeeping format for the trig addition formulas. Matrix multiplication looks new, but what it actually computes is «rotate by α, then by β — the same as one rotation by α+β».
Animated · drag the point on the circle and watch the four numbers of the rotation matrix update live — a matrix is not a table, it is a moving ledger
The site's /k/A1/ covers four representations of orientation — that is the full version. This lesson does one thing only: starting from the addition formulas, so that the first time you meet a matrix it does not read like gibberish.
Why this tool exists
«Where is the arm's end-effector» = transforming the end-effector coordinates from the joint frame all the way to the base frame. Each transformation is one rotation plus one translation.
Expanded, each rotation's coordinate conversion is a combination of four trig functions. Expanding every time is exhausting, so people packed them into a matrix.
«Rotate by A, then by B» is written as one line of matrix multiplication; multiply it out and it is exactly the addition formulas.
Definitions
Rotation about the origin
In the plane, after rotating point (x, y) counterclockwise about the origin by angle θ it lands at (x', y'): x' = x·cosθ − y·sinθ, y' = x·sinθ + y·cosθ. In matrix form, R(θ) = [[cosθ, −sinθ], [sinθ, cosθ]] times the column vector (x, y).
Why define it this wayThis definition is not arbitrary — once written as a matrix, the composition «rotate by α then by β» automatically produces the addition formulas; see the first theorem below.
Theorems and proofs
Theorem 1 (composition)
R(α)·R(β) = R(α+β).
Proof
Expand by the definition of matrix multiplication, cell by cell: top-left = cosα·cosβ − sinα·sinβ, which by the addition formulas equals cos(α+β); top-right = −cosα·sinβ − sinα·cosβ = −sin(α+β); bottom-left = sinα·cosβ + cosα·sinβ = sin(α+β); bottom-right = −sinα·sinβ + cosα·cosβ = cos(α+β).
All four cells match the four cells of R(α+β) one by one, hence R(α)·R(β) = R(α+β).
NoteThis is where «matrix multiplication = composition of actions» comes from. A whole chain of coordinate transforms in robotics (camera → end-effector → base) is essentially this theorem applied repeatedly.
Theorem 2 (length preservation)
Rotation does not change length: x'² + y'² = x² + y².
Proof
Substitute x' = x·c − y·s and y' = x·s + y·c (c=cosθ, s=sinθ): x'² + y'² = (xc−ys)² + (xs+yc)² = x²c² − 2xycs + y²s² + x²s² + 2xycs + y²c².
The cross terms cancel, leaving x²(c²+s²) + y²(s²+c²) = x² + y² (using c²+s²=1).
NoteSo the matrix only rotates; it never stretches or squashes a point. Stretching matrices (scaling/shear) exist in robotics too, but orientation representation always uses the «non-stretching» kind.
Work it by hand
Rotate the point (1, 0) by 90°, then by another 90° — use matrix multiplication to find where it ends up.
- R(90°) = [[0, −1], [1, 0]] (cos90°=0, sin90°=1).
- R(90°)·R(90°): top-left = 0×0 − 1×1 = −1; top-right = 0×(−1) − 1×0 = 0; bottom-left = 1×0 + 0×1 = 0; bottom-right = 1×(−1) + 0×0 = −1. The product = [[−1, 0], [0, −1]], exactly R(180°).
- (1, 0) times it = (−1, 0).
(−1, 0). Two 90° rotations equal one 180° rotation — the hand-computed version of Theorem 1.
Run the numbers
Where the numbers come from
Real run in double-precision floats: 1000 random points, rotated by 37° then by 53°, compared point by point against a direct 90° rotation (the generator computes for real):
- Max coordinate error = 4.4e-16×10^-16 — at the level of double-precision machine epsilon; the two routes are numerically indistinguishable.
- Conclusion: chaining dozens of rotation matrices in robot code differs from «one rotation straight to the target» only at the 1e-15 scale — the error does not come from this notation.
Where this shows up
| The object here | The counterpart in RL | Used in |
|---|---|---|
| Rotation matrix R(θ) | The first tool of orientation / coordinate transformation | used in → |
| Matrix multiplication composition | The transform chain camera → end-effector → base | used in → |
| 2D rotation | The 3D homogeneous transform SE(3) | used in → |
Boundaries: where this article stops
This lesson stops in 2D. The four representations of 3D rotation, gimbal lock, and quaternion double cover all live in the full version at /k/A1/. In 2D, rotating by α then β equals the reverse order (Theorem 1 holds both ways); in 3D, rotations about different axes do not — that pit belongs to the full version.
Self-test: 3 questions
All hand-computation and «find the flaw in this proof» questions — nothing to memorize. Stuck? Go back to the section.
01In 2D, do «rotate 30° then 60°» and «rotate 60° then 30°» give the same result? What about 3D?
In 2D, yes — both equal a 90° rotation (Theorem 1). In 3D, rotations about different axes do not commute — there is a numerical counterexample in A1.
02Hand-compute the top-left cell of R(45°)·R(45°) using the addition formulas — what should it equal?
cos45°cos45° − sin45°sin45° = 1/2 − 1/2 = 0 = cos90°. The top-left cell is 0, exactly matching a 90° rotation.
03Where does the point (0, 1) land after a 90° rotation?
x' = 0×0 − 1×1 = −1 and y' = 0×1 + 1×0 = 0, giving (−1, 0). It lands on the negative x-axis.