🧱 Tesseract
About this simulation
A tesseract, or 8-cell, is the four-dimensional analogue of the cube. Just as a cube is bounded by six square faces, a tesseract is bounded by eight cubical cells. It cannot exist rigidly in our 3D world, but its shadow can: by rotating its 16 vertices in 4D and projecting them down to three dimensions, we can watch the hypercube twist and fold in ways an ordinary cube never could. The tesseract is the standard first example used to build intuition for higher-dimensional geometry.
How it works
- 16 vertices are placed at every combination of ±1 in four coordinates (x, y, z, w).
- 32 edges connect every pair of vertices that differ in exactly one coordinate (Hamming distance 1).
- Each frame, the vertices are rotated in the xw, yw and zw planes by independently accumulating angles.
- The rotated 4D points are perspective-projected into 3D using the w coordinate before being drawn.
Key equations
4D rotation in plane (a,b) by angle θ: a' = a·cos(θ) - b·sin(θ), b' = a·sin(θ) + b·cos(θ), with the other two coordinates unchanged. The xw, yw and zw rotations are composed in sequence each frame.
Perspective projection from 4D to 3D: scale = d / (d - w), then (x, y, z) · scale, where d is the projection distance and w is the point's fourth coordinate after rotation.
Controls
- XW / YW / ZW rotation speed — set the speed of rotation in each of the three 4D planes that involve the w axis.
- Projection distance — controls how strong the perspective effect is as points move through the w dimension.
- Hide/Show vertices — toggle the small spheres marking each of the 16 vertices.
- Pause / Reset — freeze the 4D rotation or restore all angles and sliders to their defaults.
- Autorotate — toggle automatic orbiting of the 3D camera view.
Did you know?
A tesseract has 16 vertices, 32 edges, 24 square faces and 8 cubic cells — following the four-dimensional generalisation of Euler's formula. When rotated purely in a plane that includes the w axis, a tesseract appears to turn itself inside out, an effect impossible for any solid rotating in ordinary 3D space.