# Hypercube

**Update:**I’ve written an iOS app,

*The Fourth Dimension*, that explains what a hypercube is and lets you rotate it in 3D and 4D.

A friend of mine was reading a book about the fourth dimension and was
having a hard time visualizing hypercubes (specifically, the 4D instance
of a hypercube, which mathematicians call a *tesseract*),
so I wrote a program so
he could play with one interactively.

The user can rotate around the hypercube, or perform direct-manipulation rotations in 4D.

For a 4D rotation, the 3D vector described by the dragging of the mouse in the plane of the screen combined with the 4D unit vector (0 0 0 1) specify two basis vectors of a four-dimensional plane of rotation.

This is a lot more intuitive than a set of sliders.

Before I show an example of the 4D rotation, wrap your head around this simple 3D rotation of a regular old cube.

In the above sequence, the red square is the back face of the cube. It’s smaller than the other squares because it’s farther away from the viewer. As it the cube rotates around 90 degrees, the red square becomes a trapezoid.

Here’s the hypercube. Instead of a bunch of squares connected together, it’s a bunch of cubes all fused into a big weird mess.

The red cube is smaller than the others because it’s farther away from the viewer, four-dimensionally. The red cube sits exactly in the center of the hypercube.

Now the hypercube is rotated through the fourth dimension. Throughout this sequence, the mouse is being dragged a little bit down and mostly to the right. Essentially it’s like grabbing the front of the hypercube and spinning it, only in 4D.

At this point, the red cube is about to be pushed through the left wall of the hypercube.

As the red cube rotates around toward you through the fourth dimension, it becomes trapezoidal.

If I kept rotating the red cube around, it would eventually stretch out around to the “outside” of the hypercube and everything would look red. This is analagous to what would happen in the first sequence with the cube if the red square was rotated completely around to the front.

The transparent walls of the hypercube are drawn in such a way that they become slightly less transparent as they are angled edge-on to the camera. This approximates a thick-walled surface and some kind of Fresnel effect that real glass has, which I don’t exactly understand.