Skip to content
Tactiverge

Textbooks/The Mathematics of Machines/Chapter 5

5Matrices and transformations

Version 1 · Technically checked (automated checks only) · 3 source lessons · 8 practice items

Text
All chapters and search
  1. 1. Algebraic modelling
  2. 2. Functions as models
  3. 3. Trigonometry and periodic motion
  4. 4. Vectors
  5. 5. Matrices and transformations
  6. 6. Rates of change
  7. 7. Accumulation and integrals
  8. 8. Differential equations
  9. 9. Probability and uncertainty
  10. 10. Linear systems
  11. 11. Eigenvalues and stability

Introduction

A 2×2 matrix is a machine that takes in a vector and gives back a moved one. Its columns tell you where the two axis arrows land, which is enough to know where everything else goes. This chapter multiplies matrices and vectors, builds the rotation matrix from scratch, and shows why the order of two transformations matters and how to undo one.

(1, 0) stays(0, 1) → (1, 1)A = [[1, 1],[0, 1]]det A = 1dashed: before · filled: after
Figure 5.1. Where the columns land. A unit square with corners (0,0), (1,0), (1,1), (0,1) is transformed by the matrix with columns (1, 0) and (1, 1). The first axis arrow stays at (1, 0), the second moves to (1, 1), and the square becomes a parallelogram with the same area, because the determinant is 1.

Explanation

This chapter is built from 3 School lessons. Each part below is the lesson's own explanation; open the lesson for its predict-and-discover activities.

5.1 A matrix is a machine that moves vectors

Four numbers in a box can rotate, stretch, shear or flip an entire plane at once. How do they know where everything goes?

The recipe

For M = [a b; c d] and v = (x, y): M·v = (a·x + b·y, c·x + d·y). Each output component is one row of M dotted with v. A 2×2 matrix takes a 2D vector to another 2D vector.

Columns are where the axes land

M·(1, 0) = (a, c), the first column. M·(0, 1) = (b, d), the second column. Any vector (x, y) = x·(1, 0) + y·(0, 1), so M·v = x·(column 1) + y·(column 2). To design a matrix, decide where (1, 0) and (0, 1) should go and write those as columns. Grid lines stay straight, parallel and evenly spaced: that's what 'linear' means.

The determinant

det M = ad − bc is the factor by which areas change. det = 1: areas kept (rotations). det = 2: doubled. Negative: the plane is flipped over (a mirror image). det = 0: the plane is squashed onto a line or a point, information is lost, and the matrix cannot be undone.

Common mix-ups

  • The rows of a matrix tell you where the axes go.
    ✓ The columns do: column 1 is where (1, 0) lands, column 2 where (0, 1) lands.
  • A negative determinant means the matrix shrinks things.
    ✓ The size of det is the area factor; the minus sign means a flip (mirror image).

Open the full lesson: A matrix is a machine that moves vectors →

5.2 The rotation matrix, built from scratch

Every robot, game engine and spacecraft turns things with the same four entries: cos, −sin, sin, cos. Where does that minus sign come from?

Using R(θ)

To rotate a point about the origin by θ (anticlockwise positive): x′ = x cos θ − y sin θ, y′ = x sin θ + y cos θ. For a clockwise rotation, use a negative θ: cos stays the same, sin changes sign. To rotate about some other pivot, shift the pivot to the origin, rotate, then shift back.

What makes it a rotation

Its columns are unit length and perpendicular to each other, so lengths and angles are kept (it is 'orthogonal'), and det = 1, so it doesn't mirror. A matrix with orthonormal columns but det = −1 is a reflection, not a rotation.

Same matrix, two stories

R(θ)·p can mean 'turn the point p by θ' or 'p is given in a frame turned by θ; here it is in the outer frame'. Both are the same calculation. Robotics uses the second story constantly: a link frame rotated by θ1 turns the link's own coordinates into the base frame's.

Derivation: Deriving R(θ)
  1. A matrix is fixed by where it sends (1, 0) and (0, 1): those images are its columns.

  2. Rotating (1, 0) by θ lands on the unit circle at angle θ: (cos θ, sin θ). That's column 1.

  3. (0, 1) starts at 90°, so after rotating it is at θ + 90°: (cos(θ + 90°), sin(θ + 90°)) = (−sin θ, cos θ). That's column 2, and the source of the minus sign.

  4. So R(θ) = [cos θ −sin θ; sin θ cos θ], and R(θ)·(x, y) = (x cos θ − y sin θ, x sin θ + y cos θ).

  5. Check lengths: (x cos θ − y sin θ)² + (x sin θ + y cos θ)² = x²(cos² + sin²) + y²(sin² + cos²) + (cross terms that cancel) = x² + y². Lengths are kept.

  6. Check area: det R = cos θ · cos θ − (−sin θ) · sin θ = cos²θ + sin²θ = 1. No stretching, no flipping.

Common mix-ups

  • The minus sign in R(θ) goes on the bottom-left entry.
    ✓ It goes top-right: column 2 is where (0, 1) lands, (−sin θ, cos θ). Rebuild it from a sketch if unsure.
  • A rotation matrix rotates about any point you like.
    ✓ It rotates about the origin. For another pivot, translate, rotate, translate back (or use a homogeneous transform).

Open the full lesson: The rotation matrix, built from scratch →

5.3 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?

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.

Common mix-ups

  • A·B is 'A first, then B'.
    ✓ Acting on a vector, A·B·v applies B first. Read products right to left.
  • The inverse of a product reverses each matrix but keeps the order.
    ✓ (AB)⁻¹ = B⁻¹A⁻¹: undo the last thing first.

Open the full lesson: Order matters: composing and undoing matrices →

Worked examples

A matrix is a machine that moves vectors: example 1

Find [2 −1; 1 3]·(4, −2).

Solution

Row 1: 2×4 + (−1)×(−2) = 8 + 2 = 10. Row 2: 1×4 + 3×(−2) = 4 − 6 = −2. Answer (10, −2).

The rotation matrix, built from scratch: example 1

Rotate (3, 4) by 90° clockwise.

Solution

θ = −90°: cos = 0, sin = −1. x′ = 3×0 − 4×(−1) = 4, y′ = 3×(−1) + 4×0 = −3. (4, −3): length still 5.

Order matters: composing and undoing matrices: example 1

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

Solution

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. ✓

Interactive figures

Figure 5.2 from A matrix is a machine that moves vectorsTry each preset and describe it in words. Then choose Custom and build: (a) a matrix that triples heights only, (b) one that swaps x and y, (c) one that squashes the plane onto a line. For each, watch where the orange (1, 0) and green (0, 1) arrows land, and the determinant.
Can't use the interactive? Read a description instead

The matrix grid shows the plane before (fine grid) and after (blue grid) applying the matrix. An orange arrow shows where (1, 0) lands, a green arrow where (0, 1) lands, and a purple patch shows the transformed unit square. A test point (1.5, 1) and its image P′ are joined by a dashed arrow. The readout lists the matrix, both columns, P′ and the determinant.

Interactive figure (online). Description: The matrix grid shows the plane before (fine grid) and after (blue grid) applying the matrix. An orange arrow shows where (1, 0) lands, a green arrow where (0, 1) lands, and a purple patch shows the transformed unit square. A test point (1.5, 1) and its image P′ are joined by a dashed arrow. The readout lists the matrix, both columns, P′ and the determinant.

Laboratory

Everything runs in your browser. No kit, nothing mains-powered. Simulations are simplified educational models.

  • Equation Lab exploration

    Equation Lab: Matrices

    Build a rotation by 90°, apply it twice and predict the result before you look.

    Open Equation Lab: Matrices →
  • Playground lab

    Playground: Robotic kinematics

    Treat each joint as a rotation and check that changing the order of two rotations moves the tip somewhere else.

    Open Playground: Robotic kinematics →

Guided practice

Answers are checked on the server; wrong answers get a hint and another try. Signed in, solved items also count towards the source lesson.

Practice 1

[3 1; 0 2]·(2, 5): what is the first component?

Practice 2

Which matrix sends (1, 0) to (0, 2) and (0, 1) to (−1, 0)?

Practice 3

What is the determinant of [4 2; 3 1]?

Practice 4

Which matrix is R(90°)?

Practice 5

The point (5, 12) is rotated by 73°. What is its distance from the origin afterwards?

Practice 6

Rotate (3, 1) by 90° about the pivot (2, 1) (not the origin). What is the new y coordinate?

Practice 7

[1 2; 3 4]·[5 6; 7 8]: what is the entry in row 2, column 1?

Practice 8

In A·B·v, which transformation is applied to v first?

  1. [3 1; 0 2]·(2, 5): what is the first component?
  2. Which matrix sends (1, 0) to (0, 2) and (0, 1) to (−1, 0)?
    • [0 −1; 2 0]
    • [0 2; −1 0]
    • [0 −1; 0 2]
    • [2 0; 0 −1]
  3. What is the determinant of [4 2; 3 1]?
  4. Which matrix is R(90°)?
    • [0 1; −1 0]
    • [0 −1; 1 0]
    • [1 0; 0 1]
    • [−1 0; 0 −1]
  5. The point (5, 12) is rotated by 73°. What is its distance from the origin afterwards?
  6. Rotate (3, 1) by 90° about the pivot (2, 1) (not the origin). What is the new y coordinate?
  7. [1 2; 3 4]·[5 6; 7 8]: what is the entry in row 2, column 1?
  8. In A·B·v, which transformation is applied to v first?
    • A
    • B
    • Both at once
    • It depends on the determinant

Engineering applications

  • Robot frames

    A camera on a robot arm sees the world in its own frame. A chain of rotation (and translation) matrices converts what it sees into the frame of the robot's base.

  • Graphics and screens

    Every rotated, scaled or sheared shape on a screen is drawn by multiplying its corner coordinates by a matrix, usually millions of times a second.

Watch

Optional verified videos. Nothing loads from YouTube until you press play.

Shows every 2D vector as a mix of two basis arrows, which is exactly why a matrix's columns tell you where those arrows land.

9 min 59 s · captions on YouTube · source

Nothing loads from YouTube until you press play.

Shows a matrix as a description of where the basis vectors land, so you can read a transformation straight off its columns.

10 min 58 s · captions on YouTube · source

Nothing loads from YouTube until you press play.

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

10 min 3 s · captions on YouTube · source

Nothing loads from YouTube until you press play.

  • Linear combinations, span, and basis vectors | Chapter 2, Essence of linear algebra (3Blue1Brown)
  • Linear transformations and matrices | Chapter 3, Essence of linear algebra (3Blue1Brown)
  • Matrix multiplication as composition | Chapter 4, Essence of linear algebra (3Blue1Brown)

Chapter summary

  • A·v is a combination of A's columns weighted by v's components.
  • The columns of A are where the axis vectors (1, 0) and (0, 1) land.
  • R(θ) = [[cos θ, −sin θ], [sin θ, cos θ]] rotates by θ and keeps lengths.
  • A·B means apply B first, then A; in general A·B ≠ B·A.
  • The determinant is the area scale factor; zero means the matrix squashes the plane flat and cannot be undone.

Glossary

Matrix multiplication
Multiplying matrices combines rows of the first with columns of the second: each entry of the result is a dot product of a row and a column.
2D rotation matrix
A 2D rotation by angle θ anticlockwise maps (x, y) to (x cos θ − y sin θ, x sin θ + y cos θ), written as a 2×2 matrix.
Vector addition
Vectors are added component by component: the x parts add, the y parts add, and the result is the single vector with the same effect as both.

Definitions from the Field Guide.

Project: A two-joint arm with matrices

Compute the tip position of a two-link planar arm for three pairs of joint angles using rotation matrices. Then swap the order of the two rotations in your calculation and show, with numbers, that the answer changes.

Deliverables

  • The matrices used
  • Tip positions for three poses
  • The swapped-order result and an explanation

Keep your work in your Engineering Journal; it stays private unless you choose to share it.

References

  • Gilbert Strang (2016). Introduction to Linear Algebra, 5th edition. Wellesley-Cambridge Press.
  • MIT OpenCourseWare (2010). 18.06 Linear Algebra (Spring 2010). Massachusetts Institute of Technology. Link ↗

Further reading from the source lessons

Publication record

Version
1
Status
Technically checked (automated checks only)
Technical review
Automated checks only, last run 2026-11-29. No human, educator or mentor review is claimed.src/content/textbooks/textbooks.test.ts: schema, every lesson, diagram, practice item, video, Field Guide entry, lab and reference resolves; figure numbers recomputed; no practice answers in client payloads.
Written by
Compiled and written by the Tactiverge team with AI assistance, from Tactiverge School lessons that were themselves written with AI assistance.
Licence
All rights reserved by the founders unless a licence is approved.
Corrections
None recorded yet.Spotted a mistake? Use “Report a problem” on any chapter, or see the corrections page.