Skip to content
Tactiverge

Mathematical concepts

2D rotation matrix

Also called: rotation matrix · rotate a point · R(θ)

Definition

A 2D rotation by angle θ anticlockwise maps (x, y) to (x cos θ − y sin θ, x sin θ + y cos θ), written as a 2×2 matrix.

Picture it

The columns of the rotation matrix are where the x and y axes end up after rotating. Robots use rotation matrices to convert a point seen in the robot's frame into the world frame.

The maths

R(θ) = [cos θ  −sin θ; sin θ  cos θ]
p_world = R(θ) p_robot + t
SI units used in this entry
QuantityUnitSymbol
angleradianrad
lengthmetrem

Worked example

A robot facing 90° (anticlockwise from world x) sees an obstacle 2 m straight ahead, at (2, 0) in its own frame. The robot is at (1, 1). Where is the obstacle in the world frame?

  1. R(90°) (2, 0) = (2 cos 90° − 0, 2 sin 90° + 0) = (0, 2)
  2. Add the robot's position: (0 + 1, 2 + 1) = (1, 3)

AnswerAt (1, 3) m in the world frame.

✓ The 2 numbers in this answer are recomputed from scratch by an automated test.

Common misconceptions

  • Misconception: Clockwise versus anticlockwise conventions flip the sign of sin θ; check which one your library uses.
  • Misconception: Rotate first, then translate: the order changes the answer.