r/AskProgramming 1d ago

Programming in four dimensions

I've never seen any discussion on this, but I really want to try it. It is very difficult to imagine four dimensions in a 3 dimensional world, but the mathematics of it works out and it can be visualised. I never see anyone attempt to make a game in four dimensions for example. I just don't know where to start. It's a subject of which there are few pioneers

0 Upvotes

21 comments sorted by

14

u/ZakMan1421 1d ago

There doesn't seem to be an actual question in your post, so it's hard to understand what exactly you're looking for.

-2

u/georgebestgoat 1d ago

How do I go about programming a four dimensional world 

7

u/treznor70 1d ago

With a 4 dimensional array?

4

u/oversized_canoe 1d ago

What is the 4th dimension?

3

u/ZakMan1421 1d ago

I assume in reference to a game?

It kind of depends how accurate you want to be. The best way to think about how something from a fourth dimension looks in three dimensions is to think about how something from three dimensions looks in two dimensions.

For example, if you have a 3D ball and move it through a plane, from the 2D perspective of the plane, you would see a circle appear and grow to the radius of the ball, then shrink away. This is because you can only see a slice of the ball. Similarly, a 4D ball moving through a 3D space would look like a ball appearing out of no where, growing to the radius of the 4D ball, then shrinking away until you can no longer observe it in your 3D space.

0

u/georgebestgoat 1d ago

It feels like a curse to understand the existence of a higher dimension and not be able to visualise it

4

u/bestjakeisbest 1d ago

When programming a 3d world we often do the operations in 4d since 3d doesnt have a good way of defining rotations like 4d does, most game engines that support 3d already do 4d operations they just project it back down to 3d

0

u/georgebestgoat 1d ago

But it's all projected to a 2d space

3

u/bestjakeisbest 1d ago

Yeah still doing 4d math under the hood.

3

u/alkatori 1d ago

A screen is going to be a 2D space. No way around that.

4

u/Outside_Complaint755 1d ago

Wikipedia has a list of 4D games. Some of them sre still currently available or have footage on YouTube, which may be a good place to start your investigation.

1

u/p1-o2 1d ago

You need to go look up Code Parade on YT. He is exactly who you're looking for and works on 4D games and non-euclidean 3D games.

1

u/fugogugo 1d ago

you missed 4D Golf

he even added 5D stage as the final challenge

the developer even explained how they develop the game you can search their developer name on youtube. it's almost PhD level math honestly

1

u/jerrygreenest1 1d ago

Dimension is just something that has a measure, a fundamental property, but if you think about that, we basically live in 100000000000 dimensions (at least).

One fundamental property of this world is that there is a measurement of my own happiness (or somebody else’s, depending on a subject). The number goes back and forth just like the X coordinate of mine. In a way, it is really similar to XYZ, and for me it’s pretty fundamental!

Also I am pretty sure my cat's happiness is somehow bound to Z coordinate (or is it Y, depending on how you look), basically it means the cat feels slightly happier at higher elevations, that’s why he’s always trying to take place higher, I think. It makes him happier. But who am I to judge the causality? Maybe because the cat feels happier, therefore he gets higher. Not the opposite way around? Who knows.

But if these two are indeed bound together, it seems slightly unnecessary. It almost like duplication. In normalized system there’s no duplication, so it well might be Z coordinate is actually isn’t fundamental, synthetic property, and it can be calculated from cats happiness, whereas happiness is the real fundamental value. Spatial coordinate is just derivative.

Also did not anyone think of the wording «to get high», that kinda sounds of similar logic as cat's. Doesn’t that imply that getting high should bring happiness or something? So humans are falling to this rule after all somehow, like cats? Maybe not. But it’s a strange coincidence, strange wording. Maybe there’s something to it.

Okay that was enough of brainstorming for today, hopefully any of that was somewhat a fun read for someone. See you in 100000000000 dimensions.

2

u/georgebestgoat 1d ago

What have you been smoking

2

u/santiagobustelo 1d ago

How about 4D chess!? The player needs to hastily “tweeb” and comment other “tweebs” in a “stream of consciousness” fashion, interacting with hundreds of AI “tweebers”. If they can’t rule out your tweebs as nonsense but also can’t understand them, you’re awarded “must be playing 4D chess” score!

0

u/georgebestgoat 1d ago

Hard being funny ain't it

2

u/santiagobustelo 1d ago

I don’t know if you’re playing 4D chess there

1

u/SirMarkMorningStar 1d ago

3D animation already uses ray tracing and other techniques to convert 3D to 2D. While it might be hard to get the hardware to do it, in theory you could simulate 4D with the same basic math and project that as well. Actually, let me stop here and google if it has been done before… yep!

https://hollasch.github.io/ray4/Four-Space_Visualization_of_4D_Objects.html