Skip to content
Tactiverge

Textbooks/Robotics From First Principles/Chapter 4Lite (plain text) version

4Rotations and transforms

Version 1 · Technically checked (automated checks only) · 4 source lessons · 7 practice items

Text
All chapters and search
  1. 1. Sense, think, act
  2. 2. Actuators and drives
  3. 3. Vectors and frames
  4. 4. Rotations and transforms
  5. 5. Forward kinematics
  6. 6. Inverse kinematics
  7. 7. Motion and trajectories
  8. 8. Where am I? Drift, uncertainty and fusion

Introduction

A matrix is a machine that moves vectors. The rotation matrix turns any arrow by an angle without stretching it, and a homogeneous transform packs a rotation and a shift into one matrix so that chains of frames become chains of multiplications. Order matters: rotate then shift is not shift then rotate. With transforms you can walk from the world to a gripper and back again.

(2, 0)(1.732, 1)(2.732, 1.5)30°rotate 30°, then shift (1, 0.5)
Figure 4.1. Rotate, then shift. The vector (2, 0) rotated by 30° becomes (1.732, 1); shifting that by (1, 0.5) gives (2.732, 1.5). One homogeneous transform performs both steps at once.

Explanation

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

4.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 →

4.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 →

4.3 Homogeneous transforms: rotate and shift in one matrix

A 2×2 matrix can't move the origin. Add a row of 0, 0, 1 and suddenly it can. What is that extra 1 doing?

The 3×3 transform

T = [cos θ −sin θ tx; sin θ cos θ ty; 0 0 1] describes a frame turned by θ with its origin at (tx, ty) in its parent. Top-left 2×2: the rotation. Right column: where the frame's origin is. Bottom row: always 0, 0, 1. Points go in as (x, y, 1).

Reading T_parent←child

We label transforms by what they convert: T_WA turns coordinates in frame A into coordinates in the world W. So p_W = T_WA · p_A. Its columns even tell a story: column 1 is A's x axis seen in W, column 2 is A's y axis, column 3 is A's origin in W.

Points and directions

Points (positions) carry a 1: they get rotated and shifted. Directions (velocities, forces, axes) carry a 0: they get rotated only, because moving a frame doesn't change which way an arrow points. Keeping that last coordinate right is a common source of bugs in robot code.

Derivation: Why the extra row of 0, 0, 1 works
  1. A rigid move is p′ = R·p + t: rotate, then add a translation. The '+ t' is not a matrix multiplication, so a 2×2 matrix can't do it.

  2. Trick: write points with an extra coordinate fixed at 1: p = (x, y, 1).

  3. Build T = [R t; 0 0 1] = [cos θ −sin θ tx; sin θ cos θ ty; 0 0 1].

  4. Multiply: row 1 gives x cos θ − y sin θ + tx·1, row 2 gives x sin θ + y cos θ + ty·1, row 3 gives 0 + 0 + 1 = 1. That is exactly R·p + t, with the 1 still in place.

  5. The 1 picks up the translation column. (A direction vector, which shouldn't be shifted, is written with a 0 instead, and correctly ignores t.)

Common mix-ups

  • You can translate first and rotate after, it makes no difference.
    ✓ T = [R t] means rotate the local point, then add t. Shifting first would rotate the shift too.
  • The bottom row 0 0 1 is decoration.
    ✓ It keeps the final 1 in place so that transforms can be multiplied together and chained.

Open the full lesson: Homogeneous transforms: rotate and shift in one matrix →

4.4 Chains of frames, and the way back

A camera on a wrist on an elbow on a shoulder sees a bolt. To grab it, the robot must know where the bolt is in the room. How many matrices is that?

Chaining: labels like dominoes

T_WB = T_WA · T_AB: the A's in the middle 'cancel'. For a longer chain, T_W←tool = T_W←base · T_base←1 · T_1←2 · T_2←tool. Multiply left to right in the order of the chain; the point goes in on the right. In 2D, the angles of a chain simply add, and the translations combine through the rotations.

Inverting a rigid transform

To go the other way (W → A), use T_AW = T_WA⁻¹. For a rigid transform no general inverse is needed: T⁻¹ = [Rᵀ −Rᵀt; 0 0 1]. Rotate back by −θ, and the new translation is the old one, rotated back and negated. Check: T⁻¹·T = I.

Up and down the tree

To get a camera's measurement into the gripper frame you might go up from camera to world and back down to gripper: T_gripper←camera = T_W←gripper⁻¹ · T_W←camera. Every arrow you traverse backwards needs an inverse. Writing the subscripts carefully is the whole skill.

Common mix-ups

  • The inverse of a transform just negates the angle and the translation.
    ✓ The angle negates, but the new translation is −Rᵀt: the old shift, rotated back, then negated.
  • Transforms can be multiplied in any order as long as all of them are included.
    ✓ Only the order that chains the frame labels gives the right answer.

Open the full lesson: Chains of frames, and the way back →

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.

Homogeneous transforms: rotate and shift in one matrix: example 1

Write T for a frame rotated 30° with origin (1, 2), and find the point (2, 0) in the parent.

Solution

T = [0.866 −0.5 1; 0.5 0.866 2; 0 0 1]. T·(2, 0, 1) = (1.732 + 1, 1 + 2, 1) = (2.732, 3).

Chains of frames, and the way back: example 1

T_WA has θ = 90°, t = (2, 1). Find T_AW and use it to express the world point (2, 3) in A.

Solution

Rᵀ = R(−90°). −Rᵀt: Rᵀ(2, 1) = (1, −2), negated (−1, 2). So T_AW = (−90°, (−1, 2)). Point: R(−90°)(2, 3) + (−1, 2) = (3, −2) + (−1, 2) = (2, 0). Check: T_WA·(2, 0) = (0, 2) + (2, 1) = (2, 3). ✓

Interactive figures

Figure 4.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.

Figure 4.3 from Homogeneous transforms: rotate and shift in one matrixSet frame B's rotation and shift to 0, so only frame A matters. Put A at 90°, shift (2, 1), and p at (1, 0). Check the world position against your prediction, and read T_WA. Which entries hold the rotation? Which hold the shift?
Can't use the interactive? Read a description instead

The frame-chain viewer draws the world axes in black, frame A in blue and frame B in orange (solid arrow for x, dashed for y), with point p as a lime dot. The readout shows p in B, in A and in the world, and prints the 3×3 matrices T_WA, T_AB and their product T_WB.

Interactive figure (online). Description: The frame-chain viewer draws the world axes in black, frame A in blue and frame B in orange (solid arrow for x, dashed for y), with point p as a lime dot. The readout shows p in B, in A and in the world, and prints the 3×3 matrices T_WA, T_AB and their product T_WB.

Laboratory

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

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

Which matrix is R(90°)?

Practice 4

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

Practice 5

Frame rotated 0° with origin (4, −1). Point (2, 3) in that frame. What is its parent x coordinate?

Practice 6

Which is T_W←tool for the chain world → base → link → tool?

Practice 7

T has θ = 0° and t = (3, −2). What is the x translation of T⁻¹?

  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. Which matrix is R(90°)?
    • [0 1; −1 0]
    • [0 −1; 1 0]
    • [1 0; 0 1]
    • [−1 0; 0 −1]
  4. The point (5, 12) is rotated by 73°. What is its distance from the origin afterwards?
  5. Frame rotated 0° with origin (4, −1). Point (2, 3) in that frame. What is its parent x coordinate?
  6. Which is T_W←tool for the chain world → base → link → tool?
    • T_W←base · T_base←link · T_link←tool
    • T_link←tool · T_base←link · T_W←base
    • T_W←base + T_base←link + T_link←tool
    • T_W←base⁻¹ · T_link←tool
  7. T has θ = 0° and t = (3, −2). What is the x translation of T⁻¹?

Engineering applications

  • Robot software frameworks

    Robot software keeps a tree of frames, map to robot to arm to camera to gripper, each joined by a transform. Asking where the camera sees a cup in map coordinates is a walk along that tree, multiplying transforms.

  • Games and graphics

    Every object in a video game is drawn by multiplying its points by a chain of transforms: model to world, world to camera, camera to screen. The same mathematics places a robot hand.

Watch

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

Shows that a rotation matrix's columns are just the body's axes written in the world frame.

2 min 53 s · captions on YouTube · source

Nothing loads from YouTube until you press play.

Sets up frames and rigid-body motion, the shared language of the next chapters of Modern Robotics.

2 min 10 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.

  • Modern Robotics, Chapter 3.2.1: Rotation Matrices (Part 1 of 2) (Northwestern Robotics)
  • Modern Robotics, Chapter 3: Introduction to Rigid-Body Motions (Northwestern Robotics)
  • Linear transformations and matrices | Chapter 3, Essence of linear algebra (3Blue1Brown)

Chapter summary

  • Multiplying a matrix by a vector moves the vector; the columns show where the axes go.
  • A rotation matrix turns vectors by an angle and keeps their lengths.
  • A homogeneous transform combines a rotation and a translation in one 3 × 3 matrix.
  • Chains of transforms multiply in order; the inverse walks the chain backwards.

Glossary

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.
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.
Coordinate frame
A coordinate frame is an origin plus a set of axes used to describe positions and directions. Robots use several: world, base, each joint, sensors and the tool.

Definitions from the Field Guide.

Project: A frame tree

Model a desk lamp with a base, two arms and a head as a chain of four frames. Choose angles and lengths, write each homogeneous transform, multiply them to find where the bulb is, and invert the chain to express a point on the desk in the bulb's frame.

Deliverables

  • A labelled sketch of the four frames
  • Each transform written out
  • The bulb position and the inverted point, checked in code

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

References

  • Kevin M. Lynch and Frank C. Park (2017). Modern Robotics: Mechanics, Planning, and Control. Cambridge University Press.
  • John J. Craig (2005). Introduction to Robotics: Mechanics and Control, 3rd edition. Pearson Prentice Hall.
  • Mark W. Spong et al. (2006). Robot Modeling and Control. Wiley.

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.