Ad Space — Top Banner

2D Rotation Matrix

The 2D rotation matrix transforms coordinates by angle θ, rotating points around the origin using cosine and sine functions.

The Formula

x' = x cos(θ) − y sin(θ)
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:

[x'] [cos(θ) −sin(θ)] [x]
[y'] = [sin(θ) cos(θ)] [y]

Variables

SymbolMeaning
(x, y)Original point coordinates
(x', y')Rotated point coordinates
θAngle of rotation (positive = counterclockwise)
R(θ)The 2×2 rotation matrix

Key Properties

PropertyExplanation
Preserves distancesThe rotated point is the same distance from the origin as the original
Preserves anglesThe shape of any figure is unchanged — no stretching or shearing
Determinant = 1The matrix has det(R) = cos²θ + sin²θ = 1
Inverse = transposeR(−θ) = R(θ)ᵀ — rotating backward is the transpose
ComposableR(α) × 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:

  1. Translate: subtract the center (x − cx, y − cy)
  2. Rotate using the matrix above
  3. 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)

Ad Space — Bottom Banner

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.