TactivergeLite

Lite / Intelligent Robotic Systems / Week 14

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?

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

Why should I care?

Real frames are both turned and shifted: a gripper sits at the end of an arm, a lidar is bolted to the front of a car. Homogeneous transforms let one matrix do both, so that chaining frames becomes a simple multiplication. They are the everyday currency of robot software (ROS calls its frame library tf).

Predict

A frame is rotated 90° and its origin is at (2, 1). A point is at (1, 0) in that frame. Where is it in the parent frame?

  1. (3, 1)
  2. (2, 2)
  3. (1, 2)
  4. (0, 1)
Guess first, then reveal

(2, 2). Rotate first: (1, 0) turned 90° is (0, 1). Then shift by the origin: (0 + 2, 1 + 1) = (2, 2). (3, 1) forgets the rotation; (0, 1) forgets the shift.

Discover

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

What the interactive shows (text version)

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.

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

Understand

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.

Explain it another way

Intuitive

The homogeneous matrix is a 'pose card': it says how a frame is turned and where its origin is. Hand it a point written in the frame, and it hands back the same point in the parent's coordinates.

Technical

Rigid transforms in 2D form the group SE(2). Homogeneous coordinates embed it in 3×3 matrices so that composition is matrix multiplication and the action on points is linear in (x, y, 1).

Mathematical

θ = 120°, t = (3, −4), p = (−3, 2): x = (−0.5)(−3) − (0.866)(2) + 3 = 1.5 − 1.732 + 3 = 2.768; y = (0.866)(−3) + (−0.5)(2) − 4 = −2.598 − 1 − 4 = −7.598.

Applied

A self-driving car's software holds a transform from the lidar frame to the car frame (fixed, measured at the factory) and one from the car frame to the map (updated many times a second). Every lidar point is multiplied by both.

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

Worked example 1

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

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

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 T = [c −s tx; s c ty; 0 0 1], what does the column (tx, ty, 1) mean?
Practice 4. A force direction (1, 0) in a sensor frame must be expressed in the robot frame. How should it be written for the homogeneous transform?

Apply it

A lidar is mounted 0.4 m in front of a robot's centre and rotated 180° (it faces backwards). It sees an object at (1.5, 0.2) m in its own frame. Write T_robot←lidar and find the object in the robot frame. Is it in front of or behind the robot?

Reflect

Why do you think robot software stores the pose of every sensor as a transform, rather than as separate 'angle' and 'offset' numbers?

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

Go further

← Order matters: composing and undoing matricesChains of frames, and the way back →