Don Stephenson Don Stephenson

Rotation Matrices Explorer

Show
⚠ Gimbal lock: β ≈ 90° or 270° — α and γ now turn the sphere around nearly the same world axis, so one rotational degree of freedom is temporarily lost. That's a real property of Euler angles, not a bug in this tool.
View orthonormal camera, never touches R
Rotation controls
Radians
0.00
sin(γ)
0.00
cos(γ)
1.00
1.00 0.00 0 0.00 1.00 0 0 0 1
Radians
0.00
sin(β)
0.00
cos(β)
1.00
1.00 0 0.00 0 1 0 0.00 0 1.00
Radians
0.00
sin(α)
0.00
cos(α)
1.00
1 0 0 0 1.00 0.00 0 0.00 1.00
Equivalent Rotation Euler's theorem — one axis, one angle
trace(R)
3.00
θ
R = I — no single axis is defined at θ=0°
Matrix R
1.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 1.00
col X̂′col Ŷ′col Ẑ′
DRAG A SLIDER TO ROTATE R · PICK A PRESET

This tool renders a unit sphere with a small hand-rolled 3-D pipeline (orthographic projection, backface culling, painter's-algorithm depth sort, flat color fill — no simulated lighting) — no 3-D library, consistent with every other tool on this site. Where the Unit Sphere Explorer is about a single vector's rectangular and polar representations, this tool is about orientation: how three independent rotations compose into one 3×3 matrix, and the one real limitation of that scheme — gimbal lock.

1. The sphere itself is a sine/cosine tuple

Every vertex of the mesh is generated directly from spherical coordinates, $p(\theta,\varphi) = (\cos\varphi\cos\theta,\ \cos\varphi\sin\theta,\ \sin\varphi)$ — the exact 3-D generalization of the $(\cos\theta,\sin\theta)$ pair the Unit Circle Explorer traces in 2-D. What you see rotate is that fixed sine/cosine mesh, transformed by $p' = Rp$. The dashed "generative triangles" make this literal: for each plane, the cos leg and sin leg construct the exact point $R\cdot(\cos\text{angle},\sin\text{angle})$ that plane's own slider currently traces on its ring, and the solid radius out to that point is the unit vector reaching the sphere — the same construction as the circle tool, just carried through R.

2. Composing three elemental rotations

Each slider builds one elemental rotation matrix about a coordinate plane:

  • $\alpha$ rotates in the YZ-plane (about $\hat X$): $R_x(\alpha)=\begin{bmatrix}1&0&0\\0&\cos\alpha&-\sin\alpha\\0&\sin\alpha&\cos\alpha\end{bmatrix}$
  • $\beta$ rotates in the XZ-plane (about $\hat Y$): $R_y(\beta)=\begin{bmatrix}\cos\beta&0&\sin\beta\\0&1&0\\-\sin\beta&0&\cos\beta\end{bmatrix}$
  • $\gamma$ rotates in the XY-plane (about $\hat Z$): $R_z(\gamma)=\begin{bmatrix}\cos\gamma&-\sin\gamma&0\\\sin\gamma&\cos\gamma&0\\0&0&1\end{bmatrix}$

They compose as $R=R_z(\gamma)\,R_y(\beta)\,R_x(\alpha)$ — $\alpha$ is applied first, $\gamma$ last. Every one of R's 9 entries is a product of sines and cosines of these three angles; that's the "matrix built from cosines" the sidebar displays live, and it's exactly what each slider's own mini 3×3 grid shows in isolation — the same 9 positions, with everything but that one rotation's own block dimmed out.

3. Why dragging α never lights up column 1

Multiplying the three matrices out shows column 1 of R (where $\hat X$ lands) is $(\cos\gamma\cos\beta,\ \sin\gamma\cos\beta,\ -\sin\beta)$ — a function of $\beta$ and $\gamma$ only, never $\alpha$. That's not a coincidence: $R_x(\alpha)$ fixes $\hat X$ in place by construction, so a rotation confined to the YZ-plane can never move a vector that starts on the X axis. The matrix-cell highlight when you drag a slider is computed from this exact dependency (worked out symbolically for this fixed composition order), not a blanket "everything changed" guess. $\beta$, sitting in the middle of the product, is the only slider that reaches all 9 cells.

4. One axis, one angle: Euler's rotation theorem

However R was built — three sliders, any order — it is always equivalent to a single rotation by some angle $\theta$ about some fixed axis $\hat n$. The angle falls straight out of the trace: $\text{tr}(R)=1+2\cos\theta$, because a rotation by $\theta$ leaves one direction ($\hat n$ itself) fixed and turns the plane perpendicular to it, contributing $1+2\cos\theta$ to the sum of eigenvalues regardless of which axis that plane sits on. The axis itself falls out of R's antisymmetric part: $R-R^{\mathsf T}=2\sin\theta\,[\hat n]_\times$, so $\hat n \propto (R_{32}-R_{23},\,R_{13}-R_{31},\,R_{21}-R_{12})$. That readout and the dashed magenta line through the sphere are computed from the live composed R, not from $\alpha$, $\beta$, $\gamma$ directly — it's the same matrix, seen through its own eigenstructure instead of through the three angles that built it. Two cases need a different formula: at $\theta=0$ (R is the identity) no axis is defined at all, and at $\theta=180°$ the antisymmetric part vanishes ($\sin 180°=0$), so the axis is instead read off the diagonal of $\tfrac12(R+I)$, which reduces to $\hat n\hat n^{\mathsf T}$ at exactly that angle.

5. Gimbal lock, shown rather than just described

Three independent "rotate about a plane" sliders are Euler angles, and Euler angles have a well-known failure mode: when the middle rotation $\beta$ reaches $90°$ or $270°$, $R_x(\alpha)$ and $R_z(\gamma)$ end up rotating around the same physical world axis. A degree of freedom collapses — turning $\alpha$ and turning $\gamma$ start doing the same thing to the sphere. Drag $\beta$ to $90°$ to see it directly; the callout that appears is this tool's way of teaching the limitation instead of hiding it. It is a genuine property of any three-independent-angle orientation scheme, not a bug specific to this demo.

6. Color-coding the three principal planes

The three rings are the rotated images of the YZ-, XZ-, and XY-plane great circles — an armillary-sphere view of exactly the three planes the sliders rotate within, each ring colored to match its control (red/teal/violet, same as the Rotation Controls accents). The sphere's own surface carries none of that coloring: it's a single flat, unlit fill with no gradient, no simulated light, and no per-triangle tint, so nothing on the ball itself can be mistaken for shading. Color on screen means exactly one thing — "this is a principal plane, and this is which control moves it" — carried entirely by the rings and the labeled basis-vector arrows (X′/Y′/Z′), never by the sphere's surface.

7. Pedagogical flow

  1. Reset (α=β=γ=0) and move only $\alpha$: watch column 1 of R never change.
  2. Reset again, then move only $\beta$: watch every cell change, and the two other rings tilt with it.
  3. Drag $\beta$ to $90°$ and nudge $\alpha$ and $\gamma$ in turn — notice they now spin the sphere around the same axis (gimbal lock).
  4. Turn on "Basis vectors" alone and watch the labeled X′/Y′/Z′ triad tilt as one rigid unit — that triad, at any given moment, is R's three columns.
  5. Set two different angle combinations that land $\beta=0$ vs. $\beta\ne0$ but the same $\theta$ — the dashed magenta equivalent-axis line and its angle readout confirm two different-looking Euler triples can still be the same net orientation.
  6. Compare against the Unit Sphere Explorer: one free vector, shown in both polar and rectangular form — the sibling lesson this tool grew out of, without the rotation-composition layer.
PROJECT: LIGHTSTRUC AISHEET: TOOLS · ROTATION MATRICESSOURCE: tools-rotation.htmlREV 1.1