RobotGuide
Math foundations/The Matrix Is a Ledger for Rotation

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.

≈ 25 min2 theorems4 proof steps3 self-test questions

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.

  1. R(90°) = [[0, −1], [1, 0]] (cos90°=0, sin90°=1).
  2. 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°).
  3. (1, 0) times it = (−1, 0).
Answer

(−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 hereThe counterpart in RLUsed in
Rotation matrix R(θ)The first tool of orientation / coordinate transformationused in →
Matrix multiplication compositionThe transform chain camera → end-effector → baseused in →
2D rotationThe 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.

Up next

The full series · 27 articles

T1The Matrix Is a Ledger for Rotation≈ 25 minT2From Slope to Gradient: The First Line of Every Robot Learning Algorithm≈ 25 minT3Vectors and forces: the physical reading of the dot productAbout 20 minT4Two Rulers and a Better Rulerabout 25 minT5The Ledger of One Motor Revolution: Radians, Speed, and Powerabout 20 minT6Complex multiplication is rotation: the one-dimensional version of quaternionsAbout 20 minT7Bases and coordinates: why robots put everything in matrices45 minT8Matrix Multiplication: Chaining Transformations, Not a Table OperationAbout 40 minT9The Jacobian: Rotate a Joint One Degree — How Far Does the End Effector Move?About 45 minT10Eigenvectors: The Directions a Matrix Dare Not Touchabout 45 minT11SVD and the Pseudoinverse: When There Is No Exact Solution, Find the Nearest Oneabout 50 minT12Taylor expansion: putting a straight line to work in place of a curveAbout 40 minT13Probability spaces: why «random» needs axioms50 minT14Expectation: A Rigorous Construction of «Average»About 55 minT15Conditional Expectation: What the Vertical Bar Really Means≈ 60 minT16Four inequalities: the quantitative answer to «how many samples are enough»45 minT17Norms and fixed points: where «it always converges» comes from55 minT18Markov Chains: When the Time Average Equals the Ensemble Averageabout 55 minT19The Mathematical Construction of the MDP: What One Axiom Is Worthabout 50 minT20Dynamic Programming: The Accounting for Two Iterations≈ 50 minT21Optimization: why constraints cannot rely on penalties aloneAbout 55 minT22Stochastic Approximation: Every Term in the Learning-Rate Formulaabout 55 minT23The Mathematics of Contact: Hertz Theoryabout 45 minT24Friction and the Friction Cone: The Geometry of Constraintsabout 40 minT25Force Closure and Grasp Metrics: ε Is a Linear ProgramAbout 50 minT26Contact Kinematics: Why Rolling Is Not «Sliding Along»≈ 45 minT27Slip detection: from «I felt it» to «I computed it»About 50 min