Ad Space — Top Banner

Rotation Matrix Calculator

Compute 2D and 3D rotation matrices and apply them to a point.
Supports rotation about x, y, z axes with degrees-or-radians input and live visualization.

Rotation Matrix

Rotation matrices are the workhorse tool of computer graphics, robotics, physics, and engineering. They describe how to rotate a vector around a fixed origin without changing its length. Every transformation you see in 3D games, every joint motion in a robot arm, and every change of reference frame in physics passes through one of these matrices.

2D rotation (counterclockwise by angle θ):

R(θ) = [ cos θ −sin θ ] [ sin θ cos θ ]

Apply it to a 2D point (x, y) by ordinary matrix multiplication:

[x’] [ cos θ −sin θ ] [x] [ x·cos θ − y·sin θ ] [y’] = [ sin θ cos θ ] [y] = [ x·sin θ + y·cos θ ]

The result (x’, y’) is the original point rotated counterclockwise by θ around the origin.

3D rotation, axis-aligned:

Three elementary rotations, one per axis. All counterclockwise when looking down the positive axis toward the origin (right-hand rule).

Rx(θ) = [ 1 0 0 ] [ 0 cos θ −sin θ ] [ 0 sin θ cos θ ]

Ry(θ) = [ cos θ 0 sin θ ] [ 0 1 0 ] [ −sin θ 0 cos θ ]

Rz(θ) = [ cos θ −sin θ 0 ] [ sin θ cos θ 0 ] [ 0 0 1 ]

Rotation about an arbitrary axis is a composition of these (Euler angles, Rodrigues’ formula, or quaternions for higher accuracy).

Why determinant = 1, transpose = inverse:

Rotation matrices are orthogonal: R·Rᵀ = I and det(R) = +1. This is what makes them rotations rather than reflections or general linear maps. The determinant being +1 (not −1) preserves orientation; orthogonality preserves length and angles. Together these properties define the special orthogonal group SO(2) for 2D and SO(3) for 3D.

A useful practical consequence: to invert a rotation, you don’t compute a matrix inverse — you just transpose. R⁻¹ = Rᵀ. This is much faster numerically and avoids the floating-point drift that would otherwise creep in during long animation sequences.

Worked example, 2D rotation by 90°:

Take the point (3, 1). Rotate counterclockwise by 90°: cos 90° = 0, sin 90° = 1.

[x’] [ 0 −1 ] [3] [ −1 ] [y’] = [ 1 0 ] [1] = [ 3 ]

So (3, 1) → (−1, 3). Visualize this: the original point sits to the right and slightly up; after a 90° rotation it sits to the left and well up. Confirms the math.

Worked example, 3D rotation about z-axis by 45°:

Take the point (1, 0, 5). cos 45° = sin 45° ≈ 0.7071.

Rz(45°) · (1, 0, 5) = (0.7071, 0.7071, 5)

The z-coordinate is unchanged (z-axis rotations don’t move points along z), and the (x, y) part rotates from the +x direction to the diagonal +x+y direction.

Composing rotations:

To apply two rotations in sequence, multiply the matrices. Order matters. R_A · R_B applied to a vector means “first apply R_B, then apply R_A”:

[ R_A · R_B ] · v = R_A · (R_B · v)

This non-commutativity is why pitch, yaw, and roll angles depend on convention. The same three angles applied in a different order produce a different orientation. Aerospace, robotics, and game engines often use different conventions for this reason.

Euler angles and gimbal lock:

Decomposing an arbitrary 3D rotation into three axis-aligned angles (typically yaw, pitch, roll or ZYX Tait-Bryan) is convenient for humans but introduces a problem called gimbal lock. When the middle axis aligns with one of the outer axes (e.g., pitch = 90°), two of the three angles become indistinguishable; you lose one degree of freedom. This is why aerospace systems use quaternions or rotation matrices directly for navigation rather than Euler angles, even though Euler angles are easier to read.

Rodrigues’ formula (rotation about arbitrary axis):

For a unit axis vector k = (kx, ky, kz) and angle θ:

R = I + sin θ · K + (1 − cos θ) · K²

where K is the cross-product matrix of k:

K = [ 0 −kz ky ] [ kz 0 −kx ] [ −ky kx 0 ]

Rodrigues’ formula is the cleanest way to compute a rotation matrix from an axis-angle representation; quaternion conversions use the same math under the hood.

Common uses:

  • Computer graphics: every 3D engine multiplies meshes by rotation matrices in real time.
  • Robotics: forward kinematics (joint angles → end-effector position) is rotation matrices stacked together. Inverse kinematics (position → joint angles) is the harder reverse problem.
  • Aerospace and aviation: attitude representation, INS/GPS integration, autopilot control.
  • Crystallography: symmetry operations of crystal lattices are all rotation matrices.
  • Image processing: image rotation, registration between images taken from different angles.

Numerical issues:

After many compositions, floating-point error makes a rotation matrix slightly non-orthogonal. Standard fix: re-orthonormalize periodically using Gram-Schmidt or SVD. Game engines do this every few frames; aerospace systems do it on every cycle.


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.