## Drawing 4-Dimensional Shapes

by on Mar.15, 2016, under Concepts, On Game Development, Software and Games, Uncategorized

I have always had a great interest in multi-dimensional shapes. The idea that there could be a whole “dimension” of space that exists in dimensions beyond those that we can see is fascinating.

Human beings are used to seeing in three dimensions, length, breadth, and depth. In computer graphics these are generally labelled as X,Y, and Z.

However, there are an unlimited number of dimensions possible. Since humans only see the world in 3 dimensions, it is not possible to “create” a true 4 dimensional or higher object, but it is possible to create a representation of one of these shapes.

The secret is something called “Projection“. This is a mathematical means of mapping a higher dimensional structure onto a lower dimensional structure.

As a computer games programmer, I am very familiar with projection. Computer games, for now at least, are played on screens, which are two dimensional, while most games themselves, are three dimensional.

This means that it is necessary to do a “window to viewport transformation”. This basically “projects” the Z axis, or the depth information, onto the screen, while preserving the X and Y axis. This means that a 3D object can be drawn accurately onto a 2D screen.

The same technique works at higher dimensions. By fixing two axes, X and Y, in the same way as the 3D to 3D projection, and then projecting the other axes, (however many there are) it is possible to create a 2D representation of the higher dimensional shape.

These shapes look bizarre, especially when animated. This is because the way they are constructed and the way the move is completely unlike anything we are used to dealing with. We understand 3D objects, since we live in a 3D world. We also understand 2D objects, because 2D is a subset of 3D, but 4D objects seem to be “impossible”, even though they follow the same rules as other objects.

To demonstrate what a 4D object is, and how it is constructed, I constructed a “Tesseract” by following THIS tutorial. A tesseract is basically a cube in 4D.

First, here is a 1-Dimensional object, a simple line. containing only length information: Then, a 2-Dimensional object, a square. Containing both length and width information: Now there is a problem, because the screen is only two dimensions. So, how is it possible to represent a 3-dimensional shape, such as a cube, which contains depth information as well? The answer is simple, draw a representation of that cube: This is not a true cube, but it can be essentially thought of as a “snapshot” of a cube at a given position and rotation. This idea of the “snapshot” will become important shortly. First, take a look at the tesseract, the 4-Dimensional cube: This obviously looks very complex, but look closely, and you will see that it is essentially a series of interlocking cubes. Now, take a look at this image, which I obtained (HERE) from the wikipedia page on the tesseract:

This is also a tesseract, but it looks completely different. Why? This is simply because the viewing angle and rotation is different, producing a vastly different projected shape. Wikipedia has two examples of rotating tesseracts. The first (left) shows rotation about one plane, and the second (right) shows rotation about two planes:  These animations look impossible, and seem to violate the rules of physics. Yet what is happening here is exactly the same as what would happen if a cube was rotated about one or two of it’s axes, the only difference is that another dimension is involved, and our brains can’t truly comprehend it.

I have toyed with the idea of writing either a program or a library (probably for Torque) that can render higher dimensional shapes. It would be very interesting to see what they look like when using the Oculus Rift, especially since the rift is a true 3D device, and therefore would only need a 4D to 3D projection, and not a 4D to 2D.

There is a game by the name of Miegakure (and another game or concept project which I played some time ago, I believe that it was called Daedalus) which created 4D game worlds. This lends itself well to complex reasoning and puzzle solving. It seems that with enough practice, human beings can in fact learn to “process” the fourth dimension, and make some sense of it.

I don’t know if a 4D first person shooter has ever been created, I doubt it, but it would definitely be a fascinating concept to develop.