If you’re a nerd, you probably have encountered visualizations of a tesseract: a four-dimensional equivalent of a cube. Heck, various representations of the shape have made it into blockbuster sci-fi films, music videos, and more.
What might be harder to grasp is what these images mean or how they’re generated. You can find a handful of tesseract rendering demos on GitHub, but they all take different approaches, produce different results, and don’t really explain what’s going on.
In this article, we’ll take a look at the hypercube from first principles — and then, figure out how to map this beast to a computer screen.
It’s hip to be square
To build a mathematical model of the hypercube, let’s start with a square. If we get it right, our approach will generalize to three dimensions and produce a cube; if it does, it ought to extend to the hyperspace too.
More specifically, we’ll try to model the edges of a square — i.e., the line segments that connect the vertices in the four corners. For our purposes, a see-through wireframe model will work better than a solid.
For a 2D square with dimensions a×a, the horizontal edges can be described as a collection of points that satisfy two criteria:
\(\begin{array}{c} |x| \leq a \\ |y| = a \end{array}\)
In essence, we’re saying that we want to include points for which the y coordinate is equal to either -a (the lower edge) or +a (the upper edge); and where the x coordinate spans anywhere between -a and +a:
One half of a square.
... continue reading