2D Rotation Matrix Generator
Generate the standard $2\times 2$ orthogonal rotation matrix $R(\theta)$ for any angle in degrees or radians, transform vectors $(x, y) \to (x', y')$, and inspect dynamic basis vector rotations on the Cartesian plane.
2D Coordinate Transformation Canvas
Basis i → i', j → j'Matrix Multiplication & Coordinate Rotation Derivation Formula: x' = x⋅cosθ − y⋅sinθ | y' = x⋅sinθ + y⋅cosθ
How to Construct and Apply a 2D Rotation Matrix
To rotate any 2D vector or point (x, y) counter-clockwise by an angle θ around the origin, construct the 2×2 rotation matrix R(θ) = [[cos θ, -sin θ], [sin θ, cos θ]]. Then multiply this matrix by the column vector [x; y] to find the rotated coordinates: x' = x·cos(θ) - y·sin(θ) and y' = x·sin(θ) + y·cos(θ). Because R(θ) is an orthogonal matrix with determinant = 1, it perfectly preserves distances, angles, and shapes (isometry).
Anatomy of the 2D Rotation Matrix & Group Theory
In linear algebra and computer graphics, a 2D rotation matrix is an operator that rotates the Cartesian basis vectors $\mathbf{i} = (1, 0)$ and $\mathbf{j} = (0, 1)$ by an angle $\theta$ around the coordinate origin $(0, 0)$.
The rotated basis vectors form the columns of the transformation matrix:
R(θ) = [ [ cos θ, −sin θ ], [ sin θ, cos θ ] ]
Column 1: Rotated x-basis vector $\mathbf{i}' = (\cos\theta, \sin\theta)^T$.
Column 2: Rotated y-basis vector $\mathbf{j}' = (-\sin\theta, \cos\theta)^T$.
Area scaling factor is 1; no stretching or flipping.
The inverse matrix is simply its matrix transpose.
Preserves all Euclidean distances and interior angles.
Vector Transformation Formula (x', y')
To rotate an arbitrary point $P(x, y)$ by an angle $\theta$ around the origin $(0, 0)$:
First row of matrix dot product with [x; y].
Second row of matrix dot product with [x; y].
Counter-Clockwise (+θ) vs Clockwise (-θ) Formulations
In mathematics, positive angles rotate counter-clockwise. For clockwise rotation, substitute $-\theta$ using trigonometric symmetries ($\cos(-\theta) = \cos\theta$, $\sin(-\theta) = -\sin\theta$):
R_CCW = [ [cos θ, −sin θ], [sin θ, cos θ] ]
R_CW = [ [cos θ, sin θ], [−sin θ, cos θ] ]
Rotating Around an Arbitrary Center Point (h, k)
Standard rotation matrices assume the rotation pivot is the origin $(0, 0)$. To rotate around any center point $C(h, k)$, apply the three-step transformation pipeline:
- Translate to Origin: Shift coordinates by subtracting center $(h, k)$: $x_{rel} = x - h$, $y_{rel} = y - k$.
- Apply Rotation Matrix: Rotate around origin: $x'_{rel} = x_{rel}\cos\theta - y_{rel}\sin\theta$ and $y'_{rel} = x_{rel}\sin\theta + y_{rel}\cos\theta$.
- Translate Back: Add back the center $(h, k)$: $x' = x'_{rel} + h$ and $y' = y'_{rel} + k$.
Standard Transformation Matrices (30°, 45°, 60°, 90°, 180°)
| Angle θ | Radians | Rotation Matrix R(θ) | Vector Transformation (x', y') |
|---|---|---|---|
| 90° | π/2 | [ [0, −1], [1, 0] ] | (−y, x) |
| 180° | π | [ [−1, 0], [0, −1] ] | (−x, −y) |
| 270° | 3π/2 | [ [0, 1], [−1, 0] ] | (y, −x) |
| 45° | π/4 | [ [√2/2, −√2/2], [√2/2, √2/2] ] | ((x−y)√2/2, (x+y)√2/2) |
Step-by-Step Worked Matrix Transformation Problems
Rotate vector v = (4, 1) by θ = 90° counter-clockwise.
1. Form matrix R(90°) = [ [cos 90°, −sin 90°], [sin 90°, cos 90°] ] = [ [0, −1], [1, 0] ].
2. Multiply: x' = 4(0) − 1(1) = −1.
3. Multiply: y' = 4(1) + 1(0) = 4.
4. Rotated point v' = (−1, 4). Length |v'| = √((-1)² + 4²) = √17 ≈ 4.123 (Preserved!).
Common Pitfalls: Sign Errors & Coordinate Transpose
In standard counter-clockwise rotation, the negative sign belongs in Row 1, Column 2 ($-\sin\theta$). Putting the minus sign in Row 2 Column 1 produces a clockwise rotation instead!
If your codebase uses row vectors $[x, y]$, you must multiply on the right by the transpose: $[x, y] \cdot R^T(\theta)$.
Lead Developer & Founder of Basic Math Tools. Specializes in browser-native computational algorithms and applied mathematics.
Mathematics & curriculum specialists. Audited against standard algebraic and arithmetic principles.