Stage 01 · Lesson 07/12

Math for Robotics · Lesson 07

Transformations

Est. 35–45 min

Why

Why “rotate then shift” is the daily robot move

Concept

The big idea: rigid transforms (R, t)

  • A rigid transform maps points without stretching: rotation + translation.
  • Formula (column vectors): p_W = R · p_A + t
  • R is 2×2 (planar) or 3×3 (spatial). t is the origin of {A} expressed in {W}.
  • Order matters: rotate-then-translate is the usual “frame pose” story.

p_W = R(θ) · p_A + t

How it works

How it actually works, step by step

  1. Express the point in the local frame

    p_A is where the point sits relative to frame {A}.

  2. Rotate into world orientation

    Multiply by R so the local axes line up with world axes.

  3. Shift by the frame origin

    Add t — the location of {A}’s origin in world.

  4. Inverse when you need the other way

    p_A = Rᵀ (p_W − t) for a pure rotation R (R⁻¹ = Rᵀ).

Visual

Visualise it: move a frame and watch a local point

Drag the frame’s position and angle. A fixed local point’s world coordinates follow p_W = R p_A + t.

Interactive · Coordinate-frame manipulator

XwYwFrame F

Point in world

(95.0, 77.7)

p_world = origin + R(θ) · p_local

Worked example

Worked example: θ=30°, t=(0.5, 0.1) m

Code lab

Code lab: apply R and t

transform_2d.py · Python
"""Stage 1 L07 — rigid transform: rotate then translate a point."""
import math

theta = math.radians(30)
c, s = math.cos(theta), math.sin(theta)
# Point in frame {A}
px_a, py_a = 0.20, 0.05  # metres
# Origin of {A} in world, and rotation of {A} relative to world
tx, ty = 0.50, 0.10

px_w = c * px_a - s * py_a + tx
py_w = s * px_a + c * py_a + ty

print(f"θ = 30°, t = ({tx}, {ty}) m")
print(f"p in {{A}} = ({px_a}, {py_a}) m")
print(f"p in world = ({px_w:.4f}, {py_w:.4f}) m")
print("Formula: p_W = R(θ)·p_A + t")

Expected output

θ = 30°, t = (0.5, 0.1) m
p in {A} = (0.2, 0.05) m
p in world = (0.6482, 0.2433) m
Formula: p_W = R(θ)·p_A + t

Real world

Tool offsets and camera extrinsics

  • Tool offset from flange to gripper tips
  • Camera extrinsics relative to the robot base
  • Moving a part from a conveyor frame into the arm base frame

Mistakes

Common mistakes and confusions

Hardware & safety

Hardware lab and safety notes

Use a mug and your graph-paper desk. Put a dot sticker on the mug handle: that point never moves in {mug}, but its {table} coordinates change every time you turn or slide the mug.

  • Mark the mug centre as the origin of {mug}; +x points to the handle.
  • Measure the sticker in {mug} (e.g. 6 cm along x).
  • Turn the mug 30° and slide it to (20, 10) cm. Predict the sticker in {table}, then measure it.

Debugging

Debugging: when it doesn’t work

Symptom → likely cause → fix
SymptomLikely causeFix
Result is off by the translation rotatedAdded t before rotatingp_W = R·p_A + t — rotate first
Sticker lands mirroredUsed R(−θ) or swapped sin signsR(θ) = [[c, −s], [s, c]] for anticlockwise θ
Inverse gives nonsenseUsed −R instead of Rᵀp_A = Rᵀ·(p_W − t)
Numbers 1000× offt in mm, p in mSame unit for R·p and t
NoteChange one thing at a time. Most Stage 1 bugs are units (degrees vs radians, mm vs m), order of multiplication, or a frame that was never named.

Think

Think about it

Think

If R is identity, what does the transform reduce to?

Experiment

Try it in the lab: move the frame

Experiment

Move the frame

You will need

  • coordinate-frame interactive
  • Notebook

Steps

  1. Note a local point’s world coordinates at θ=0, t=(0,0).
  2. Translate the frame; confirm world point shifts by the same amount.
  3. Rotate only; confirm distance from frame origin stays constant.

Interactive · Coordinate-frame manipulator

XwYwFrame F

Point in world

(95.0, 77.7)

p_world = origin + R(θ) · p_local

Rigid motion preserves distance from the frame origin to the local point.

Knowledge check

Check your understanding

Knowledge check

1. Rigid transform preserves…

2. p_W = R p_A + t means…

3. For a rotation matrix, R⁻¹ equals…

4. t represents…

Practice quiz

Loading practice quiz…

Mini assignment

Hands-on assignment

Mini assignment

Transform story

Write a 8–12 line story of a point on a mug: express it in {mug}, then in {table} after you rotate and slide the mug. Include numbers.

Deliverables

  • Story with numbers
  • One sketch

Do this, step by step

  1. Measure the sticker in {mug}: p_A = (6, 0) cm.
  2. Turn the mug 30° anticlockwise and slide its centre to t = (20, 10) cm. Predict p_W by hand.
  3. Measure the real sticker position in {table}. Note the error.
  4. Change transform_2d.py to your numbers and confirm.

Stuck? Hints, one at a time

NoteTry the task first. Read one hint, try again, and only then read the next one.
  1. Hint 1: R·p_A = (6·cos30°, 6·sin30°) = (5.20, 3.00) cm.
  2. Hint 2: p_W = (5.20 + 20, 3.00 + 10) = (25.20, 13.00) cm.
  3. Hint 3: A 3–5 mm error is fine — your mug centre is only an estimate.

Challenges (pick by level)

  • 🟢 Easy: Same mug, θ = 0°, t = (20, 10). Where is the sticker?
  • 🟡 Medium: Use the inverse to go back from p_W = (25.20, 13.00) to p_A.
  • 🟠 Hard: Write apply(theta_deg, t, p) and invert(theta_deg, t) and test that invert(apply(p)) = p for 10 random points.

Next step

Next, Lesson 8: Frames & Reference Frames chains many such transforms. Related: camera-to-world transforms in Stage 11 — Computer Vision.

Sources

Self-attested for now — keep artifacts in your lab notebook.

Complete

Today's goal

0 of 1 done today

0-day streak
Daily goal:lessons, quizzes or assignments a day

Mark this lesson complete when you have worked the experiment, knowledge check, and assignment (even roughly).

Stuck somewhere?

Ask a doubt about this lesson

Saved with this lesson's id and your email so we can reply. Privacy · or email contact@aihubstation.in