Localization & SLAM · Theory · M2
M2-T1 — 2D Rigid-Body Transformations
Every 2D pose is a rotation and a translation. Learn the algebra once and every frame bug becomes easy to find.
Lesson M1-T4 introduced frames and poses in words and with component formulas. This lesson gives the matrix form, shows that poses form a group with an identity and inverses, derives the exact motion of a robot along an arc, and lists the numerical traps that cause most transform bugs in practice.
Learning objectives
After this lesson, you should be able to:
- Write an SE(2) pose as a 3×3 homogeneous matrix and use it to transform points and compose frames.
- Compute the inverse of a pose and verify it by multiplication.
- Derive the exact arc update for constant forward and angular velocity and compare it with the midpoint rule.
- Wrap angles correctly and avoid the common traps of angle arithmetic.
The intuition
A 2D pose answers two questions at once: how is this frame turned? and where is its origin? Those two facts are a rotation followed by a translation. Packing them into one 3×3 matrix lets you chain frames by multiplying matrices, instead of juggling sines and cosines. The price is nothing: the matrix is just a tidy container for the same three numbers.
A transform is something you can do to any point. A pose is the same thing used to describe where a frame is. They are one object seen two ways.
The mathematics
A pose (x, y, θ) written as a homogeneous matrix, and a point (px, py) extended with a trailing 1:
- TAB
- the pose of frame B in frame A. Applied to a point written in B, it gives that point in A.
- R, t
- the rotation block (2×2) and the translation (2×1) inside T.
- p~
- a point with a trailing 1: the “homogeneous” form, which lets a translation be a matrix product.
- ⊕
- pose composition: TAC = TAB TBC.
Group properties
The set of all such matrices is called SE(2), the Special Euclidean group in 2D. It has what any pose algebra needs: closure (composing two poses gives a pose), an identity (x = y = θ = 0), an inverse for every pose, and associativity (T1T2)T3 = T1(T2T3). It is not commutative: T1T2 ≠ T2T1 in general.
The inverse uses the fact that a rotation matrix inverts by transposing:
Exact motion along an arc
A robot moving with constant forward speed v and turn rate ω for time Δ traces a circular arc. Its pose change in its own starting frame is exact:
The new pose is the old pose composed with this increment. The midpoint rule from the odometry lesson, Δx = v Δ cos(Δθ/2), Δy = v Δ sin(Δθ/2), is a second-order approximation of it. For small turns they agree; for large turns in one step the midpoint rule is visibly wrong.
Angles
θ and θ + 2π are the same orientation, but a computer does not know that. Always wrap after adding angles, and compare angles through their wrapped difference:
Never subtract two raw angles and call the result an error. 179° − (−179°) = 358°, but the real error is 2°.
A worked example: chain, inverse and arc
Frame B is at TAB = (2, 1, 90°) in A. Frame C is at TBC = (3, 0, −45°) in B.
- Transform a point. The point (1, 0) in B has A-coordinates R(90°)(1, 0) + (2, 1) = (0, 1) + (2, 1) = (2, 2).
- Compose. x = 2 + cos 90° · 3 − sin 90° · 0 = 2; y = 1 + sin 90° · 3 + cos 90° · 0 = 4; θ = 90° − 45° = 45°. So TAC = (2, 4, 45°): C sits 3 m along B’s y axis, which points in A’s +y direction.
- Invert. With cos 90° = 0 and sin 90° = 1: xinv = −(0·2 + 1·1) = −1, yinv = −(−1·2 + 0·1) = 2, θinv = −90°. So TBA = (−1, 2, −90°).
- Verify. Apply TBA to the A-point (2, 2): R(−90°)(2, 2) = (2, −2); adding (−1, 2) gives (1, 0), the original B-point. ✓
- Arc versus midpoint. A robot drives v = 1 m/s with ω = π/2 rad/s for one second. Exact: Δθ = 90°, Δx = (1 / (π/2)) sin 90° = 0.6366, Δy = (1 / (π/2))(1 − cos 90°) = 0.6366. Midpoint: (cos 45°, sin 45°) = (0.7071, 0.7071). The midpoint rule is off by 0.070 m after a single step: 7% of the step length. With small steps this vanishes, with big ones it does not.
Exactly this inversion and composition are what you wrote in the Module 1 frames lab. Here it is stated as algebra, so you can check any transform by multiplication.
Engineering implications and limitations
Practical rules
- Name every transform Tto_from or Tfrom_in consistently (for example
odom_T_base). A matrix chain should read like a chain of frame names that cancel: AT_B · BT_C = AT_C. - Wrap after every angle addition and compare headings through wrapped differences. Tests with headings near ±180° catch most missing wraps.
- Prefer matrices or (x, y, cosθ, sinθ) when you average, interpolate or optimise orientation. The average of 179° and −179° is 180°, not 0°.
- Use the exact arc when steps are large (low-rate wheel odometry, fast turns). The midpoint rule is fine for 50 Hz odometry at moderate speed.
- Check composition numerically: compose a pose with its inverse and expect the identity to within about 1e-9. A wrong inverse formula passes casual tests and fails this one.
Limits
SE(2) assumes the robot lives on a flat plane. Pitch and roll on ramps, uneven ground or a drone need SE(3) (next lesson). The algebra is the same; the rotation block becomes 3×3 and the angle becomes three parameters.
Common misconceptions
“Composition order does not matter for small motions.”
For small increments the error is small but systematic, and it accumulates exactly like odometry drift. The order is part of the definition, not a detail.
“The inverse of (x, y, θ) is (−x, −y, −θ).”
Only the heading is simply negated. The translation of the inverse is −Rᵀt: it must be rotated back into the other frame.
“Averaging headings is averaging numbers.”
Angles live on a circle. Average the vectors (cos θ, sin θ) and take atan2, or work with rotation matrices.
“The midpoint rule is the exact motion.”
It approximates the arc with a chord at the half angle. It is accurate for small steps and 7% off for a 90° turn in one step.
Engineering takeaways
- A 2D pose is a 3×3 homogeneous matrix; composing frames is matrix multiplication.
- Poses form a group: closure, identity, inverses, associativity, but no commutativity.
- The inverse is (Rᵀ, −Rᵀt), not the negated components.
- Exact arc motion is Δx = (v/ω) sinΔθ, Δy = (v/ω)(1 − cosΔθ); the midpoint rule is its small-step approximation.
- Always wrap angles and compare headings through wrapped differences.
References and further reading
Primary papers and authoritative documentation.
- Barfoot, T. D. (2017). State Estimation for Robotics. Cambridge University Press, chapters 6 and 7.
- Solà, J., Deray, J. and Atchuthan, D. (2018). A micro Lie theory for state estimation in robotics. arXiv:1812.01537: SE(2) and SE(3) as Lie groups, with the exponential map.
- Lynch, K. M. and Park, F. C. (2017). Modern Robotics: Mechanics, Planning, and Control. Cambridge University Press, chapter 3.
- Meeussen, W. (2010). REP 105: Coordinate Frames for Mobile Platforms.
Knowledge check
Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.
Question 1
Frame B is at (4, 0, 180°) in frame A. What are the A-coordinates of the point (1, 0) written in B?
Explanation
Rotating (1, 0) by 180° gives (−1, 0). Adding the translation (4, 0) gives (3, 0). The point is one metre from B’s origin in B’s +x direction, but B faces the other way, so it lies toward A’s origin.
Question 2
A colleague computes a heading error as θest − θtrue and gets 358°. What is the real error and how would you compute it?
Explanation
The real error is 2°. Wrap the difference: error = atan2(sin(θest − θtrue), cos(θest − θtrue)). The raw difference confuses two representations of nearly the same orientation.
Question 3
Why would you use the exact arc update rather than the midpoint rule for a robot spinning fast with a 5 Hz odometry stream?
Explanation
Each step then contains a large turn, and the midpoint rule’s error grows with the turn angle per step (about 7% of the step length for 90°). The exact arc formula has no such error, so it removes a systematic bias that would otherwise accumulate.
What’s next
Real robots, and every drone, work in 3D. Next, the same ideas with rotations that do not commute even in the plane of one step.
Related content
Nothing below is required to finish this lesson. The last 2 entries are lessons of other courses on this site that teach the background or go further.
- BeforeM1-T6: Sensors Used in SLAM
Compare LiDAR, cameras, IMUs, wheel encoders, GPS and radar by what they measure, their noise and their failure modes.
- LabM2-L1: Transform Points Between Coordinate Frames
Implement compose, inverse and point transform for 2D poses and use them to put sensor points into the world frame.
- Linear AlgebraTwo-Dimensional Rotations
Rotation matrices in the plane from first principles.
- Linear AlgebraIntroduction to Lie Groups and Lie Algebras
Planar rotations as the first example of a Lie group: the idea behind every “update on the manifold” in this track.
Get notified when the next lesson and new labs are released.
One email per new lesson or lab.