What exactly is a tesseract ?
A tesseract is just a four-dimensional cube. We can also generalize the cube in dimensions, in which case it is simply called a -hypercube. But how exactly do we generalize this idea of a cube? Let's start with dimension , a point. To transition to dimension , you transform the point into a continuum of points to get a line. To go to dimension , we transform this line into a continuum of lines to get a square. And to get the cube, we repeat the operation with a continuum of planes. You may have noticed that here, we were always extruding the next shape from the previous one in an orthogonal manner. So how are we supposed to extrude the cube into a tesseract ? Well, we simply need another dimension which is orthogonal to the three firsts, a fourth one. However, we live in a 3D world, so we can't really visualize what it is supposed to look like, but what we can do is project it in our 3D world in a way that show its important features and connections. For our projection, we are going to define the tesseract of size by its corners:
Here, represents the Cartesian product.
Once we have our points, we need to determine which points we connect. To do this, we only have to check the number of dimensions where 2 points' coordinates differ, if it is 1 then, it means the 2 points are connected.
Projecting the tesseract
We are going to use the following projection:
This is actually a stereographic projection onto the canonical 3D space. Basically in this case, it just scales a point given its 4th coordonate. If a point is in the space , it stays the same. If , it is going to scale down. And if , it is gonna scale up and approach an infinite scaling as approaches . Here, is a parameter of our projection, you need to take it large enough that no point's 4th coordinate would get too close to it.
Rotating the tesseract
Okay, now we have a tesseract and a way to project it into our 3D space.
But it is not moving yet, for this we need to rotate it and not in our 3D space,
otherwise we would just have a static projection rotating on itself.
A rotation matrix in -dimension is a matrix which inversed is its transposed self and have a determinant of 1.
This group is called the special orthogonal group of rank n : .
Here is the matrix we are going to use:
Using the already known results for 2D rotations we can verify that given that and :
Also,
and represent,
respectively, the rotation speeds for the plane and the plane.
You can also change those parameters' values with the sliders.
Final notes
You can find the (not so long) full code here.