Module 3: Transformations Lesson 1 of 3

2D Transformations

Transformations map points from one position to another. In robotics, they describe how objects move through space — a robot’s wheels rolling forward, its arm rotating, or a camera panning. We start with 2D to build intuition before tackling 3D.

Rotation in 2D

A rotation by angle θ\theta (counter-clockwise) is represented by the 2×2 rotation matrix:

R(θ)=[cosθsinθsinθcosθ]R(\theta) = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}

To rotate a point p=(x,y)\mathbf{p} = (x, y), multiply:

p=R(θ)p=[cosθsinθsinθcosθ][xy]\mathbf{p}' = R(\theta) \cdot \mathbf{p} = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}

Worked example: Rotate the point (1,0)(1, 0) by 90° counter-clockwise:

R(90°)[10]=[0110][10]=[01]R(90°) \cdot \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ 1 \end{bmatrix}

The point moves from the positive x-axis to the positive y-axis. ✓

Properties of Rotation Matrices

  • RT=R1R^T = R^{-1} (the transpose is the inverse — rotations are orthogonal)
  • det(R)=1\det(R) = 1 (rotation preserves area and orientation)
  • Rotations preserve lengths: Rv=v|R\mathbf{v}| = |\mathbf{v}|
  • Composing two rotations: R(α)R(β)=R(α+β)R(\alpha) \cdot R(\beta) = R(\alpha + \beta)

Translation

Translation shifts a point by a fixed offset:

p=p+t=[x+txy+ty]\mathbf{p}' = \mathbf{p} + \mathbf{t} = \begin{bmatrix} x + t_x \\ y + t_y \end{bmatrix}

The problem: Translation is not a matrix multiplication on a 2D vector. You can’t write p=Mp\mathbf{p}' = M \cdot \mathbf{p} for any 2×2 matrix MM that performs pure translation. This is a fundamental limitation that motivates homogeneous coordinates (Lesson 3), which elegantly combine rotation and translation into a single matrix.

For now, we represent combined transformations as: apply rotation first, then add translation.

Scaling

A scaling transformation stretches or compresses along each axis:

S(sx,sy)=[sx00sy]S(s_x, s_y) = \begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix}

Scaling in Robotics

Pure scaling is rarely used in rigid-body robotics — robots don’t change size! However, scaling appears in:

  • Sensor calibration (converting raw sensor values to physical units)
  • Image processing (resizing camera frames)
  • Simulation (adjusting model scale)

The important transforms for robotics are rotation and translation.

Transformation Composition

Applying multiple transformations in sequence is equivalent to multiplying their matrices:

Ttotal=TnT2T1T_{\text{total}} = T_n \cdot \ldots \cdot T_2 \cdot T_1

Critical insight: order matters! Matrix multiplication is not commutative. The transformations are applied right-to-left: T1T_1 first, then T2T_2, and so on.

Order matters: an example

Consider rotating 45° then translating by (2,0)(2, 0) versus translating first then rotating:

Rotate then translate: The object spins in place, then slides to the right.

Translate then rotate: The object slides to the right, then rotates — but the rotation happens around the origin, so the translated object swings in an arc!

These give completely different results.

Composition Order

For T=ABT = A \cdot B, transformation BB is applied first. Read right-to-left. Getting this wrong is one of the most common mistakes in robotics programming.

Mobile Robot Pose Robotics Application

A mobile robot on a warehouse floor has a pose described by (x,y,θ)(x, y, \theta) — its position and heading angle. If the robot is at position (2,3)(2, 3) facing 30°:

  • The rotation R(30°)R(30°) describes the robot’s orientation
  • The translation (2,3)(2, 3) describes its position

Any sensor reading in the robot’s local frame (e.g., “obstacle 1.5m ahead”) can be converted to the world frame by applying the rotation then the translation. This is exactly what the interactive demo below lets you explore.

Interactive Visualization

Adjust the rotation angle, translation, and scaling to see how an L-shaped object transforms. Toggle between individual transforms and their composition to understand how order affects the result.

Controls
-3.1415926535897933.141592653589793
1.000
-33
0.500
-33
1.000
0.13
1.000
0.13

Composite Matrix

[0.866-0.5001.000]
[0.5000.8660.500]
[0.0000.0001.000]

Transformed Center

x: 1.100, y: 1.327

Try this: Change the composition order and notice how "Rotate then Translate" gives a different result from "Translate then Rotate". In robotics, getting this order wrong can send your robot to the wrong position.

Practice Problems

  1. What does the rotation matrix look like for θ=180°\theta = 180°? What does it do geometrically?

  2. If you rotate the point (3,4)(3, 4) by 90° counter-clockwise, what is the result?

  3. You apply rotation by 45° then scaling by (2,1)(2, 1). Write the composite transformation matrix.

Answers
  1. R(180°)=[1001]R(180°) = \begin{bmatrix} -1 & 0 \\ 0 & -1 \end{bmatrix}. It flips every point through the origin (negates both coordinates). Geometrically, it’s a 180° rotation, which is the same as a point reflection through the origin.

  2. R(90°)[34]=[0110][34]=[43]R(90°) \cdot \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} -4 \\ 3 \end{bmatrix}

  3. S(2,1)R(45°)=[2001][22222222]=[222222][1.4141.4140.7070.707]S(2,1) \cdot R(45°) = \begin{bmatrix} 2 & 0 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} \frac{\sqrt{2}}{2} & -\frac{\sqrt{2}}{2} \\ \frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2} \end{bmatrix} = \begin{bmatrix} \sqrt{2} & -\sqrt{2} \\ \frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2} \end{bmatrix} \approx \begin{bmatrix} 1.414 & -1.414 \\ 0.707 & 0.707 \end{bmatrix}

Key Takeaways

  1. Rotation matrices R(θ)R(\theta) rotate points counter-clockwise by angle θ\theta
  2. Translation cannot be represented as a 2×2 matrix multiplication (motivating homogeneous coordinates)
  3. Scaling matrices stretch/compress along axes — rarely used in rigid-body robotics
  4. Transformation composition = matrix multiplication, applied right-to-left
  5. Order matters! Rotate-then-translate gives different results from translate-then-rotate

Next Steps

In 2D, rotation has a single parameter (angle). In 3D, things get much more interesting — and complicated. Next, we’ll explore 3D rotations, Euler angles, and the infamous gimbal lock problem.