Don Stephenson Don Stephenson

Unit Sphere Explorer

Show
View orthonormal camera
Direction-Cosine Vector sets n
n =
Rectangular controls — edits are renormalized back onto the sphere.
Equatorial Plane Equation normalized, n·(x,y,z)=0
1.00x + 0.00y + 0.00z = 0
DRAG θ/φ OR EDIT n · PICK A PRESET

This tool shows one unit vector n two ways at once — as a polar direction (azimuth θ, elevation φ) and as rectangular coordinates (x, y, z) — the exact 3-D generalization of what the Unit Circle Explorer does in 2-D. It's rendered with a small hand-rolled 3-D pipeline (orthographic projection, backface culling, painter's-algorithm depth sort) — no 3-D library. The Rotation Matrices Explorer is this tool's sibling: same sphere mesh, but about composing rotations rather than a single vector's two representations.

1. The sphere itself is a sine/cosine tuple

Every vertex of the mesh, and n itself, is generated directly from spherical coordinates, $$n = (\cos\varphi\cos\theta,\ \cos\varphi\sin\theta,\ \sin\varphi)$$ the exact 3-D generalization of the $(\cos\theta,\sin\theta)$ pair the Circle Explorer traces in 2-D. Drag θ and n sweeps a circle of latitude at constant elevation; drag φ and it sweeps a meridian from pole to pole. Two independent angles, two true degrees of freedom — exactly enough to reach every point on the sphere once.

2. Two controls, one vector

The polar controls (θ, φ) and the rectangular boxes (x, y, z) are two views of the same 2 degrees of freedom, kept in sync in both directions: drag a slider and the numbers update; type new numbers and they're renormalized back onto the unit sphere before θ/φ are recovered from them via $\varphi=\arcsin(z),\ \theta=\operatorname{atan2}(y,x)$. Neither representation is more "real" than the other — they're the same 2-DOF state, read out two ways.

3. x, y, and z are already the direction cosines

Because n is unit length, its rectangular components are literally the cosines of the angles it makes with each axis — $n_x=\cos\angle\hat X$, and so on — no separate calculation needed. The component box makes this a visible construction rather than a fact to memorize: it draws three axis-aligned edges laid end to end, origin → $(x,0,0)$ → $(x,y,0)$ → $(x,y,z)$, so each edge's length is exactly $|n_x|$, $|n_y|$, or $|n_z|$, anchored on its own labeled axis instead of floating as an abstract number.

4. One vector, one plane

Any unit normal defines a plane through the origin, and the live equation $n_x x + n_y y + n_z z = 0$ is exactly that — no separate normalization step, because n is already unit length. The shaded disc on the canvas is that plane clipped to the sphere; every one of the four Vector Presets aligns n with a coordinate axis, which is exactly what makes that preset's plane coincide with a familiar coordinate plane (e.g. n = $\hat Z$ makes the equation reduce to $z=0$, the XY-plane itself).

5. Pedagogical flow

  1. Start at the default (n = X̂) and read the plane equation: it should be exactly $x=0$, the YZ-plane.
  2. Drag θ alone and watch z and φ stay put — azimuth only moves you along a circle of latitude.
  3. Click "Tilt" and check the component box: three visibly different-length edges, all anchored on their own axis.
  4. Type a non-unit vector directly into x/y/z (e.g. 2, 2, 2) and watch it snap back to unit length — direction preserved, magnitude discarded.
  5. Compare against the Rotation Matrices Explorer: same sphere, but there the sliders rotate the whole mesh instead of pointing a single vector.