2D Rotation Matrix
The 2D rotation matrix transforms coordinates by angle θ, rotating points around the origin using cosine and sine functions.
The Formula
y' = x sin(θ) + y cos(θ)
The 2D rotation matrix rotates a point (x, y) by angle θ counterclockwise around the origin. The result is a new point (x', y') at the same distance from the origin but at a different angle.
In matrix form, this is written as:
[y'] = [sin(θ) cos(θ)] [y]
Variables
| Symbol | Meaning |
|---|---|
| (x, y) | Original point coordinates |
| (x', y') | Rotated point coordinates |
| θ | Angle of rotation (positive = counterclockwise) |
| R(θ) | The 2×2 rotation matrix |
Key Properties
| Property | Explanation |
|---|---|
| Preserves distances | The rotated point is the same distance from the origin as the original |
| Preserves angles | The shape of any figure is unchanged — no stretching or shearing |
| Determinant = 1 | The matrix has det(R) = cos²θ + sin²θ = 1 |
| Inverse = transpose | R(−θ) = R(θ)ᵀ — rotating backward is the transpose |
| Composable | R(α) × R(β) = R(α + β) — two rotations combine by adding angles |
Example 1
Rotate the point (3, 0) by 90° counterclockwise around the origin.
θ = 90°: cos(90°) = 0, sin(90°) = 1
x' = 3 × cos(90°) − 0 × sin(90°) = 3 × 0 − 0 × 1 = 0
y' = 3 × sin(90°) + 0 × cos(90°) = 3 × 1 + 0 × 0 = 3
(3, 0) rotated 90° becomes (0, 3) — moved from the positive x-axis to the positive y-axis
Example 2
Rotate the point (4, 2) by 45° counterclockwise.
θ = 45°: cos(45°) = sin(45°) ≈ 0.7071
x' = 4 × 0.7071 − 2 × 0.7071 = 0.7071 × (4 − 2) = 0.7071 × 2
x' ≈ 1.414
y' = 4 × 0.7071 + 2 × 0.7071 = 0.7071 × (4 + 2) = 0.7071 × 6
y' ≈ 4.243
(4, 2) rotated 45° becomes approximately (1.414, 4.243)
Rotation Around an Arbitrary Point
To rotate around a point (cx, cy) instead of the origin:
- Translate: subtract the center (x − cx, y − cy)
- Rotate using the matrix above
- Translate back: add the center (x' + cx, y' + cy)
When to Use It
The rotation matrix is fundamental in many fields.
- Computer graphics (rotating sprites, UI elements, 3D models)
- Game development (character and camera rotation)
- Robotics (joint angle calculations, coordinate transforms)
- Navigation and mapping (coordinate system conversions)
- Physics simulations (rigid body dynamics)
- Image processing (rotating photographs and scanned documents)