Don Stephenson Don Stephenson

Unit Sphere Explorer

Three sine/cosine pairs, one orientation matrix

The Unit Circle Explorer shows a single angle θ producing one sine/cosine pair — a point on a circle, and the 2×2 rotation matrix [cosθ,−sinθ; sinθ,cosθ] built from it. This tool is that same idea carried into 3-D: every point on the sphere below is generated from spherical coordinates, a literal sine/cosine tuple (cosφcosθ, cosφsinθ, sinφ). Three sliders — one rotation per coordinate plane — compose into a single 3×3 orientation matrix R, and every one of its 9 entries is built from the sines and cosines shown next to the sliders. Drag a slider to spin the sphere itself — the view is fixed, so what moves is always R, never the camera.
Sliders set the orientation X·α (YZ-plane) Y·β (XZ-plane) Z·γ (XY-plane)
View orthonormal camera, never touches R
Vector Presets sets n, not R
Rotation Angle Presets
α · YZ
β · XZ
γ · XY
Rotation controls
Degrees
Radians
0.00
sin(α)
0.00
cos(α)
1.00
Degrees
Radians
0.00
sin(β)
0.00
cos(β)
1.00
Degrees
Radians
0.00
sin(γ)
0.00
cos(γ)
1.00
⚠ Gimbal lock: β ≈ 90° — α 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.
Matrix R
1.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 1.00
col X̂′col Ŷ′col Ẑ′

R is the identity — every basis vector sits exactly on its own axis.

Direction-Cosine Vector fixed frame, independent of R
n =
Rectangular controls — any edit is renormalized back onto the sphere.
Direction cosines (n·X̂, n·Ŷ, n·Ẑ)
cos∠X̂
1.00
cos∠Ŷ
0.00
cos∠Ẑ
0.00
Equatorial Plane Equation normalized, n·(x,y,z)=0
1.00x + 0.00y + 0.00z = 0
Plane shadows
YZ-plane
Angle
sin
0.00
cos
1.00
XZ-plane
Angle
sin
0.00
cos
1.00
XY-plane
Angle
sin
0.00
cos
1.00
Show
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. The sections below explain the math it's actually showing, and are explicit about the one real limitation of the three-slider design: 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.

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. 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 $\pm90°$, $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.

5. 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 legend and the slider 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 basis-vector arrows, never by the sphere's surface.

6. 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. Click each Vector Preset (YZ/XZ/XY Plane) and watch that same-named shadow readout collapse to the origin — n is now exactly perpendicular to that plane, which is what makes it that plane's equator.
  5. Compare against the 2-D case on the Unit Circle Explorer: one angle, one sine/cosine pair, one 2×2 matrix — the same idea, one dimension down.
PROJECT: LIGHTSTRUC AISHEET: TOOLS · UNIT SPHERESOURCE: tools-sphere.htmlREV 1.0