The technical explanation

From coordinates
to moving geometry.

Hypercubes supply the points and edges. Plane rotations move them. Projection lets us see a lower-dimensional view.

We use column vectors, radians, and rotations centered at the origin. The formulas below describe the Android app’s rotation and projection pipeline.

1. Constructing an N-dimensional cube

The app builds a hypercube centered at the origin with side length 2. Each coordinate of each vertex is either −1 or +1. Two vertices share an edge precisely when they differ in one coordinate.

v ∈ {−1, +1}ⁿ vertices = 2ⁿ edges = n · 2ⁿ⁻¹

There are n edges incident to each vertex. Counting those connections over all vertices counts every edge twice, giving the edge formula above.

Hypercube geometry and available coordinate planes
DimensionVerticesEdgesCoordinate planes
3 · cube8123
4 · tesseract16326
5328010
66419215

The code generates vertices using the bits of their indices: one bit chooses the sign of one coordinate. Flipping one bit finds a neighboring vertex.

2. Planes generalize the familiar axis

A simple rotation turns a two-dimensional plane and fixes every vector in its perpendicular complement. In n dimensions this fixed subspace has dimension n − 2. In 3D it is a line, the familiar rotation axis. In 4D it is a plane.

For a chosen center, 3D planes through that center correspond to perpendicular axes through the center. An oriented axis and angle also encode the sign convention. This plane–axis correspondence is special to 3D; a general higher-dimensional rotation can require several planes and angles. Mathematics for Machine Learning, §3.9.3, “Rotations in n Dimensions” develops this plane-based view and defines Givens rotations (Definition 3.11).

A coordinate-plane rotation mixes just two coordinates. For an XY rotation, every other coordinate stays unchanged:

x′ = x cos θ − y sin θ y′ = x sin θ + y cos θ RXY(θ) = [ cos θ −sin θ 0 … ] [ sin θ cos θ 0 … ] [ 0 0 1 … ] [ ⋮ ⋮ ⋮ ⋱ ]

As a sign check, (1, 0, …) rotates to (0, 1, …) when θ = π/2. This is a Givens rotation: an identity matrix with a 2 × 2 rotation block in the selected coordinate rows and columns. The same construction works for XY, XW, or any other coordinate pair in any dimension. Since RᵀR = I and det R = +1, it preserves lengths, angles, and orientation.

Comparing sign conventions: LAPACK Working Note 158, §4.5, printed p. 19 displays the general n-dimensional Givens matrix with block [cos θ, sin θ; −sin θ, cos θ]. Our column-vector convention uses [cos θ, −sin θ; sin θ, cos θ], so our R(θ) equals G(−θ) in that reference. These describe the same family of plane rotations with opposite choices of positive angle.

More generally, write a point relative to a center c as u + z, with u in the rotation plane and z perpendicular to it. The result is c + R(u) + z. Points in the plane circle c. Points outside it circle the corresponding point c + z in the fixed affine subspace.

Why there are n(n − 1)/2 coordinate planes

Choose two distinct coordinate directions, ignoring their order. There are n(n − 1)/2 pairs. These elementary motions generate the rotation group SO(n). This count is also the number of its independent local parameters.

This does not mean a single rotation decomposes into that many mutually perpendicular planes. In a suitable orthonormal basis, one rotation can be decomposed into at most floor(n/2) two-dimensional rotation blocks, with any remaining directions fixed.

3. Combining rotations: order matters

Suppose A rotates XY and B rotates XW. Their shared X direction means changing the order generally changes the result. For column vectors, S = A B applies B first, then A.

vₖ₊₁ = S vₖ vₖ = Sᵏ v₀ (when S stays constant) (A B)ᵏ ≠ Aᵏ Bᵏ in general

HyperRotation constructs S from its ordered plane entries and repeats that step. Independently accumulating each plane’s angle and multiplying the resulting matrices would generally describe a different motion. Rotations in disjoint coordinate planes, such as XY and ZW, commute.

For a concrete order test, start at (1, 0, 0, 0). Let A and B each turn by 90°. A B sends the point to (0, 0, 0, 1); B A sends it to (0, 1, 0, 0).

Why a “full rotation” can be ambiguous

A simple rotation has one angle and repeats after a full turn. In 4D, a rotation can turn two perpendicular planes at different rates. A common cycle exists only when their angular frequencies are commensurate. For discrete steps, an exact repeat instead requires all active rotation-block angles to return to multiples of 2π after the same integer number of steps.

A general combined motion therefore has no universal “percentage of a full turn.” A trace in seconds works for periodic and non-periodic motion alike. In 3D, a fixed combined step has an equivalent axis, so its continuous orbit is still circular about that axis; richer multi-frequency behavior becomes possible in higher dimensions.

Enable JavaScript to compare rotation planes and trace one vertex.

Teaching presets use ordered step products. In “XY + ZW,” the second rate is √2 times the first. A finite trail may look nearly closed without establishing exact periodicity. At 5D/6D these presets keep coordinates beyond W fixed.

4. From N dimensions to the screen

The app’s dimensional reduction is an orthogonal coordinate projection into 3D. After rotation, it retains X, Y, Z and applies the chosen zoom factor s:

v = (x, y, z, w, …) p₃ = s · (x, y, z)

The higher coordinates affect the image through rotations that mix them into X, Y, or Z. There is no successive perspective division by W and the remaining higher coordinates in this implementation.

Worked 4D example

Consider the tesseract vertex (1, 1, 1, 1). An XW rotation sends x to cos θ − sin θ and w to sin θ + cos θ. Its 3D coordinate projection is therefore (cos θ − sin θ, 1, 1), before zoom.

At θ = 0 the result is (1, 1, 1); at θ = π/4 it is (0, 1, 1); at θ = π/2 it is (−1, 1, 1). A circle in the XW plane becomes a line in the 3D projection. The hidden W coordinate continues to change.

The second projection: camera to screen

The OpenGL camera sits at (0, 0, 5) and looks toward the origin. Its perspective frustum uses near distance 3, far distance 7, vertical extent −1 to +1 at the near plane, and horizontal extent adjusted for the aspect ratio a = width/height.

xNDC = 3 pₓ / [a (5 − p_z)] yNDC = 3 pᵧ / (5 − p_z) screenX = width · (1 + xNDC) / 2 screenY = height · (1 − yNDC) / 2

These formulas describe vertex centers inside the camera’s clipping range; OpenGL also handles clipping and depth. Edges and visible vertex spheres are drawn in that 3D scene. The browser illustration uses the same center-projection formulas with a fixed illustrative scale.

Projection loses information. Rotations preserve distances in N dimensions. The dimensional reduction and camera perspective can change visible distances and create overlaps. A trace crossing in the image does not demonstrate a return in the original space.

5. Accurate motion and useful traces

Android 2.0 implementation: the app keeps starting vertices fixed and accumulates a Double-precision orientation matrix Q. Each simulation step updates Q ← S Q, and vertex positions are reconstructed as v = Q v₀. Coordinates are converted to Float for rendering.

Keeping the geometry rigid:

The engine restores orthonormality every 256 active steps using modified Gram–Schmidt, preserving positive orientation. This limits numerical drift while preserving the ordered step composition. It does not make every orbit exactly periodic.

Trace vertex: the app records timestamped N-dimensional positions for one vertex and renders their 3D projections as a rolling path. Historical positions stay where they were recorded, rather than being rotated again with the object.

A 1–60 second duration slider bounds the visible history. Pause holds both geometry and trail aging. Resume continues without including time spent paused. Restart clears the trail at the current position. There is no closure detector or automatic freeze.

In the browser examples, orientation is accumulated using JavaScript’s double-precision numbers with periodic orthonormalization. These teaching illustrations demonstrate the same tracing and pause concepts available in Android Sandbox and Muse, using simplified canvas rendering.

Further reading and implementation notes

App-specific descriptions were checked against GeometryGenerator, DoubleOrientationEngine, TraceRecorder, RotationInfo, and OpenGLHypercubeRenderer in the Android 2.0 source.

Return to the visual introduction →