A 4-dimensional labyrinth

in #utopian-io7 years ago (edited)

image.png
A video

What is the project about?

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.

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".

image.png

You can see such a streching in the subsequent directions in the picture above, 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.

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.

image.png

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.

image.png

The second way is drawing slices (picture above). 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.

You can download the code from GitHub, or a binary from my blog.

Proof Of Work

Since this has been posted on Utopian, it is required to add a proof of ownership over the repository, as my Utopian username doesn't match the GitHub one.

Here is a screenshot of my logged in session:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Additionally, I claim that I am also @ebvalaim on keybase.io, which is proved to be the same as @fizyk20 on GitHub by this gist: https://gist.github.com/fizyk20/23825a74bafab6568bd5.
-----BEGIN PGP SIGNATURE-----
Version: Keybase OpenPGP v2.0.76
Comment: https://keybase.io/crypto

wsFcBAABCgAGBQJaDSiTAAoJEGgvju7n5ktH9rIP/2jIgzVrnahFzoDqgdCh3U9m
e6tDpvgfOF5WfdOwxRxaf2uBAM5PnMV3Kq21wZweFAk671NcjUlWgK9jDHz2XP1Q
hlSfL8wLR3Swb9ELP4MPO1NvE6KqCmmivIYu/1OEHmEcbpdRv/ZkNJqJQeOM+u49
7alGPJpY7IeI68vJDQStDgmTNPJZisKp4Nd5zsxPa0zY1JPseRf8p/r8kg6QRGLM
J3Qyk+JSXp5kdJrj/XjqozmzVfhEumuhkAC5LNboWtZVMSCoZhdyguvW1RNm86Bc
xHBQZsHOAmkK/xKaeOpLicSml4oeZc3z2V4do98TkI0a+NfchBOnYKTgPy5DnBZi
OmdwbITiq933eZqT3PNTZr2o3J+GcRjmoN88pZLQRxoUoa3A/yIdXwAk7vtdHICQ
Pu1w1zq8naA48IAqF7s5CsDSYtaUxJAmNjWrqqQiHvY5Ys6LTwcSUI443Z5LZ6DI
ipsTjkXi5tE0gNN8nvcWs7QvBs7HiVh9WVwzgY2FWN/BN6zV7e7W3WJWKR0p3zEo
9lDATBCJzfwIPux/ChaJVAAkjSsQBYippyudT+l+M3xybLrhE8pQcTSmvtj/1fy7
rh/OZehJ6Jj7abPeOphCJDsxJBrBq5QQ9a3ULkTYjLwQk2w4r5Xzsj4NTkGfTql3
/oVqi5lrYaZlAJAG8dIW
=+fic
-----END PGP SIGNATURE-----



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @ebvalaim I am @utopian-io. I have just super-voted you at 19% Power!

Achievements

  • I am a bot...I love developers... <3
  • Much more informative than others in this category. Good job!
  • You have less than 500 followers. Just gave you a gift ;)
  • You just got more votes than your total number of followers. Rock Star!
    Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Your contribution can't be approved yet. See the Utopian rules. Please edit your post to apply for approval. You can edit your post here.

  • Your steemit account name does not match the github one. Please provide proof of work.

edit screen

You can contact us on Discord.
[utopian-moderator]

If the user has connected their github account with Utopian can you see that? It would be an easy way to tell if it's the same person.

Fair enough.
By the way, would a signature with a Keybase key be considered a good proof, if the Keybase account is linked to the GitHub one?

Anyway, I'll add a screenshot of a logged-in session, too!

Hi! Your post has been selected by @NanoCheeZe to be upvoted by @XTDevelopment ... Don't forget to check us out - NanoCheeZe.com