4D Labyrinth


A screenshot from the program

A screenshot from the program. Click here for a video.

The 4D Labyrinth is a program allowing the user to move inside a 4-dimensional labyrinth. I'm probably losing some of the readers at this point already, so I guess I should start with an explanation of what "4-dimensional" actually means ;)

4 dimensions

Let's first make it clear that the 4th dimension in this program is not time. The relativity theory does indeed describe the world in terms of a 4-dimensional spacetime, but here it is just 4-dimensional space, without "-time".

What does it mean that the space is 4-dimensional, then? The gist of it is that there are 4 mutually perpendicular direction and determining the location of each point requires 4 numbers (coordinates).

To visualize all this a bit better, let's consider a point. A point is a 0-dimensional object. There are no directions in it, and when it constitutes all of the available space, you don't have to give any numbers to determine a location (as there is only one possibility anyway).

Let's now imagine that we "stretch" this point into a line. Now we have 1 dimension - there is one direction and we can name every point on the line with a real number (like on a number line), after which telling a number will uniquely identify a location.

Ok, next. We stretch the line in a direction perpendicular to it, getting a plane in the process. We can imagine that the plane consists of infinitely many lines, each having its points numbered. To define a location, we now have to give 2 numbers (the number of the line and the number of the point on it), which means that a plane is 2-dimensional.

Another stretching, another dimension. We can make a space out of infinitely many numbered planes. Determining a location in it will require defining 3 numbers (the number of the plane, of the line on the plane and of the point on the line). Such a space is what we live in and what we are the most familiar with.

Cubes - from 0 to 5 dimensions

Cubes - from 0 to 5 dimensions

But why should we stop at this point? Let's not stop, then, and stretch a bit more. Let's take infinitely many 3-dimensional spaces and use them to build... something. Imagination fails us at this point, our brains aren't fit to dealing with such things. Mathematics doesn't have any problem with that, though - nothing stops as from adding a fourth number and treat is as the number of the 3-dimensional space (more professionally: hyperplane) in this "something".

You can see such a streching in the subsequent directions in the picture to the right, except it's finite - that is, we don't get a line, but an interval, a square instead of a plane and so on. A 4-dimensional analog of a cube is called a hypercube or a tesseract. The picture reaches even a bit further and shows the result of stretching a tesseract in the fifth direction. Of course the image is flat in itself, so it's not an ideal representation - in reality, all edges meeting in a single vertex should be perpendicular to each other.

The program

It's quite an obvious fact that the computer screen is only 2-dimensional. How do we present 4-dimensional objects on it, then? There are two main ways of "reducing the dimensionality" of objects.

The first way is projections. Objects can be projected in many ways, but two are the most popular - orthographic projections and perspective projections. Both are presented in the picture below.

Examples of projections - orthographic and perspective

Examples of projections

The picture shows projections of 3-dimensional objects, but you can do the same with 4-dimensional ones. The only difference is that you have to project them twice - once on a 3-dimensional space, and then the result on a plane.

The red lines show an example slice of a cube - this one hexagonal

The red lines show an example slice of a cube - this one hexagonal

The second way is drawing slices (picture to the right). Each multidimensional object can be "sliced" with a less-dimensional hyperplane, thus resulting in a shape of a lower dimension. A big drawback of that is that a slice directly ignores a greater part of an object - we know absolutely nothing about what's happening outside of the given hyperplane. Nevertheless, this is the way being used in the 4D Labyrinth.

The player only sees a 3-dimensional slice of the whole space in any given moment. This slice is then drawn on the screen using a perspective projection. Movement is only possible within the slice, but the slice itself can be rotated. If we used an analogous system in a 3D application, the player could only see the hexagonal slice of a cube shown above at some point. He could move towards, away from or around it, but he could also rotate the slicing plane, which could result in changing the hexagon into a pentagon, rectangle, square, triangle...

Having cleared that up, let us show the controls in the program:

  • W/S/A/D/Q/E - move forwards/backwards/left/right/up/down
  • T/G - pitch down/up
  • F/H - roll left/right
  • R/Y - yaw left/right
  • U/J - rotate the slicing hyperplane in such a way, that invisible objects switch places with objects in front and to the back of the player
  • C/V - rotate the slicing hyperplane, switching invisible objects with those to the left/right
  • B/N - rotate the slicing hyperplane, switching invisible objects with those above/below

The player is being represented by a yellow cube. The goal is to reach the blue tesseract.

The program currently has only two levels. The first one consists of 4 tunnels, each along one of the coordinate axes. This causes one of them to be invisible initially, so that passing the level requires the player to rotate the slicing hyperplane at some point. The second level is more complex ;)

Touching the blue target automatically moves the player to the next level or ends the program.


Download “4D Labyrinth - Windows” 4d-labyrinth-win32.zip – Downloaded 526 times – 2 MB

Download “4D Labyrinth - Linux” 4d-labyrinth-linux64.zip – Downloaded 228 times – 855 KB

Download “4D Labyrinth - Mac OS” 4d-labyrinth-release-macos.zip – Downloaded 167 times – 620 KB