TactivergeLite

Lite / Intelligent Robotic Systems / Week 13

Order matters: composing and undoing matrices

Shear then rotate, or rotate then shear? A robot's hand ends up in a different place. Why should order matter for multiplication?

About 35 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

A robot arm is a chain of motions: turn the shoulder, then the elbow, then the wrist. Chaining motions is matrix multiplication, and because the order of physical motions matters, the order of matrices matters too. Knowing how to undo a matrix (its inverse) is how a robot converts world measurements back into its own frames.

Predict

R is a 90° rotation and S is a shear. For the point (1.5, 1), will R·S·p and S·R·p be the same?

  1. Yes, multiplication order never matters
  2. No, in general they differ
  3. Only if p is on an axis
  4. Only for rotations by 180°
Guess first, then reveal

They differ. Matrix multiplication is not commutative: shearing a turned shape is not the same as turning a sheared one. (Two rotations are a special case that do commute.)

Discover

Choose Shear. Set 'Combine with a 90° turn' to R·M, then to M·R. Write down P′ both times. Repeat with Rotate at 30° instead of Shear: do R·M and M·R still differ? Explain the difference.

What the interactive shows (text version)

With the Shear preset and the 'R·M' option, the point (1.5, 1) lands at (−1, 2.5); with 'M·R' it lands at (0.5, 1.5), so the two orders differ. With the Rotate preset both orders give the same result, because rotations in the plane commute.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: Watch for reading a product right to left: the matrix nearest the vector acts first.

Explains why multiplying matrices means doing one transformation after another, and why the order matters.

“Matrix multiplication as composition | Chapter 4, Essence of linear algebra” by 3Blue1Brown (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

Understand

Multiplying matrices

(A·B) entry in row i, column j = row i of A · column j of B. For 2×2: [a b; c d]·[e f; g h] = [ae + bg af + bh; ce + dg cf + dh]. The product A·B means 'first B, then A', because (A·B)·v = A·(B·v): the matrix nearest the vector acts first.

Order matters

In general A·B ≠ B·A. Physical intuition: put a book flat, rotate it 90° about a vertical axis, then flip it about a front-to-back axis; now do it the other way round. Different result. Planar rotations happen to commute, R(α)R(β) = R(α + β) = R(β)R(α), but mix in a shear, a scale or 3D rotations and order becomes everything.

Undoing: the inverse

The inverse M⁻¹ satisfies M⁻¹·M = I (the identity, [1 0; 0 1]). For 2×2: M⁻¹ = (1/det)·[d −b; −c a], which exists only when det ≠ 0. For rotations it is beautifully cheap: R(θ)⁻¹ = R(−θ) = R(θ)ᵀ (swap rows and columns). Undoing a turn is turning back.

Explain it another way

Intuitive

Putting on socks then shoes is not the same as shoes then socks. Undoing reverses the order too: shoes off first, then socks. Matrices work exactly like getting dressed.

Technical

(AB)⁻¹ = B⁻¹A⁻¹ (reverse order). Orthogonal matrices satisfy RᵀR = I, so their inverse is the transpose; this is why robot software stores rotations as orthonormal matrices and never computes a general inverse for them.

Mathematical

S = [1 1; 0 1], R = [0 −1; 1 0]. R·S = [0 −1; 1 1]; S·R = [1 −1; 1 0]. For p = (1.5, 1): R·S·p = (−1, 2.5), S·R·p = (0.5, 1.5). Different.

Applied

A drone's attitude is stored as a rotation. To express a world wind vector in the drone's body frame, the flight computer multiplies by Rᵀ: one transpose, no division, every few milliseconds.

Worked example 1

Find the inverse of M = [2 1; 5 3] and check it.

det = 6 − 5 = 1. M⁻¹ = [3 −1; −5 2]. Check row 1 · col 1: 3×2 + (−1)×5 = 1; row 1 · col 2: 3×1 + (−1)×3 = 0. ✓

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 3. In A·B·v, which transformation is applied to v first?
Practice 4. What is the inverse of R(40°)?

Apply it

With the diagram's Custom matrix, find a matrix M (not a rotation or the identity) that does commute with the 90° turn R: R·M·P = M·R·P. Describe what kind of transformation it is.

Reflect

Give one everyday pair of actions where order matters and one where it doesn't. Which kind is a planar rotation?

Write your answer on paper or in your own notes. Lite never stores what you write.

Go further

← The rotation matrix, built from scratchHomogeneous transforms: rotate and shift in one matrix →