💠 Tesseract — 4D Hypercube

A tesseract is the 4-dimensional analogue of a cube. Just as a cube has 8 vertices/12 edges/6 faces, a tesseract has 16 vertices, 32 edges, 24 square faces and 8 cubic cells. To visualise it in 2D we apply two successive projections: a 4D→3D perspective projection (viewing from W=5) followed by a 3D→2D perspective projection. Drag the canvas to rotate in the XY plane. Use the sliders to independently control all 6 rotation planes of 4D space. Vertices are coloured by their W coordinate (the "depth" in the 4th dimension). 🇺🇦 Українська

3D Rotations (drag canvas)

4D Rotations (W-plane)

Animation

Projection

Vertices16
Edges32
Faces24
Cells (cubes)8

How 4D Rotation Works

In 4D space, rotation occurs in a plane (not around an axis). There are C(4,2)=6 independent rotation planes: XY, XZ, XW, YZ, YW, ZW. Each is parameterised by a single angle θ. The 4D rotation matrix for e.g. the XW plane is the identity except for the 2×2 block [cosθ, −sinθ; sinθ, cosθ] in rows/columns 0 and 3 (treating XYZW as indices 0-3). Composing all six rotations gives the current orientation in 4D. A perspective projection from 4D with the viewer at W=d collapses (x,y,z,w)→(x·d/(d−w), y·d/(d−w), z·d/(d−w)), and then a second 3D perspective projects to screen. By slowly varying the XW angle you watch the inner cube "grow" through the outer cube — just as a 2D shadow of a rotating cube sees an inner square swell through the outer square.

About this simulation

A tesseract is the 4D analogue of a cube: 16 vertices, 32 edges, 24 square faces, and 8 cubic cells. Since we can't see in four dimensions, this visualiser applies a 4D rotation to the vertex coordinates, then a perspective projection (using a W-distance parameter) down to 3D and finally to the 2D canvas — the same trick used to draw a 3D cube's shadow on paper, just with one extra dimension folded in first.

🔬 What it shows

Unlike 3D rotation (around an axis), 4D rotation happens in a plane. There are C(4,2)=6 independent rotation planes — XY, XZ, YZ (ordinary 3D-style rotations) and XW, YW, ZW (true 4D rotations that mix the fourth coordinate W into the visible geometry). Each is driven by its own 2×2 rotation block inside the 4×4 rotation matrix.

🎮 How to use

Drag the canvas to spin the XY plane directly, or use the six sliders (XY, XZ, YZ and the 4D XW, YW, ZW sliders) to set each rotation angle independently. Anim speed auto-rotates all planes together; W distance controls how strong the 4D-to-3D perspective effect looks; Reset returns to the default orientation.

💡 Did you know?

Just as a 2D shadow of a rotating 3D cube shows an inner square appearing to swell and shrink relative to an outer one, a 3D "shadow" of a rotating tesseract shows an inner cube growing through an outer cube's faces — the visual signature of genuine 4D rotation on the XW, YW or ZW planes rather than an ordinary 3D spin.

Frequently asked questions

Why does 4D rotation use planes instead of axes?

In 3D, an axis of rotation is the line left fixed by the rotation — but in 4D, fixing a single line still leaves a whole 2D plane of freedom, so rotations are instead defined by the plane that mixes together, not the axis that stays fixed. That's why there are exactly C(4,2)=6 independent rotation planes in 4D versus 3 in 3D.

What's the difference between the XY/XZ/YZ sliders and the XW/YW/ZW sliders?

XY, XZ and YZ rotate the shape the same way ordinary 3D rotations would, keeping W untouched. XW, YW and ZW are "true" 4D rotations — they mix the invisible fourth coordinate W into X, Y or Z, which is what makes the projected shape appear to warp and turn inside-out in ways a 3D object never could.

What does the W distance slider actually control?

It sets the perspective projection distance used to collapse the 4D W coordinate down to 3D, analogous to how a camera's distance from a 3D scene affects perspective foreshortening. Larger W distance makes the projection closer to a flat (orthographic) view; smaller values exaggerate the 4D depth effect.

How many vertices, edges and faces does a tesseract have?

A tesseract has 16 vertices (each coordinate is ±1 in four dimensions), 32 edges, 24 square faces, and 8 cubic cells — following the same combinatorial pattern as a cube's 8 vertices, 12 edges and 6 faces, just one dimension up.

Why does the inner cube seem to grow through the outer one?

That's the projected effect of a genuine 4D rotation: as the tesseract rotates in a W-plane, vertices that were "far" in the fourth dimension move "close," which the perspective projection renders as the inner cube expanding and passing through the boundary of the outer cube — there's no actual overlap in 4D, only in its 2D shadow.