Graphics / Reference / Deriving the rotation equations

Deriving the rotation equations

The 2D rotation equations follow from expressing a point by its length and angle, adding the rotation angle, then expanding the resulting sine and cosine expressions back into x and y.

Let p = (x,y) have length |p| and make angle α with the positive x axis. Its Cartesian components are:

x = |p| cos α y = |p| sin α

so p = (|p| cos α, |p| sin α).

After rotating p by angle θ about the origin, its length remains |p| and its angle becomes θ + α:

x' = |p| cos(θ + α) y' = |p| sin(θ + α)

Use the identities:

cos(θ + α) = cos α cos θ - sin α sin θ

sin(θ + α) = cos α sin θ + sin α cos θ

Then:

x' = |p| cos α cos θ - |p| sin α sin θ = x cos θ - y sin θ

y' = |p| cos α sin θ + |p| sin α cos θ = x sin θ + y cos θ

The associated diagrams show p and p' with equal length, their angles from the x axis, and their horizontal and vertical projections.

Vector p forms a right triangle with the coordinate axes, showing horizontal projection x equals magnitude times cosine alpha and vertical projection y equals magnitude times sine alpha.
The coordinates of p are the cosine and sine projections of its magnitude onto the x and y axes.
Two equal-length vectors share the origin; p is at angle alpha and p-prime is rotated by theta, with projections defining x-prime and y-prime.
A rotation changes the direction from α to α+θ while preserving |p|, so the new coordinates are the projections of the same-length vector.

Builds on

Read