a2.2.0 (feature) - Absolute rotation system


Added a button to the bottom left panel: Enable/disable absolute rotation mode.

If enabled, the rotation will not use relative sliders, and will instead be applied in a consistent X->Y->Z order. Note that while this is enabled, the XY/XZ/YZ camera tilt sliders don’t work.

While the “relative” way of rotating is easy to understand, it also has a major flaw. If you’ve ever played a first person game, you might have noticed that this is not the way nearly 100% of games handle camera rotation. While initially it works the same way, you’ll notice that if you look directly upwards, rotating towards the right or left merely rotates the camera, instead of rotating it further to the right.

The reason for this is to make it not possible to tilt or flip the camera in a way that is not easily reversable. Imagine if a 3D first person game would allow you to look to the right after looking directly upwards - you would see the world tilted by 90 degrees. The 4D sim however would let you flip around the viewport as you like…and thus make it difficult to flip it back.

The reason why it took so long for me to fix this issue is because I couldn’t figure out how to. And, to be honest with you, I’m not sure if this is the best way of having implemented this either…though I’m not sure whether or not there even is one to begin with.

So, how exactly do 3D games achieve this? I initially thought of it like this: You make the X rotation in world space (it does not depend on the Y rotation) and the Y rotation should depend on the current rotation. But what do you do in 4D, where you have an additional Z rotation? What should that depend on? Or should other things depend on it?

After having thought about this problem for a while, I think I have thought out a decent approach. The core idea is to think of a wireframe of a sphere such as this with latitudal (horizontal) and longitudal (vertical) lines. If you wanted to describe points on this sphere with coordinates, the latitudal lines would be the X variable and the longitudal lines would be the Y variable. Well, how would you rotate a point on that circle? Easy, first rotate it by X (latitudal), then by Y (longitudal). Every point on that sphere can be described using only those two variables.

But how would a sphere wireframe such as this look in 4D? I would say that the best way to think about it is to think of a lot of squished down spheres making up a “hypersphere”. Since I couldn’t find a good image on Google, you’ll have to resort to using your imagination for this: Imagine cutting a sphere into many circular slices from top to bottom. Now, imagine each of these infinitely thin circular slices is another sphere. While it doesn’t look like a sphere, after all it’s squished down and infinitely thin, accept that it still is, in fact, a three-dimensional sphere.

Now, imagine this new Z coordinate as specifying the slice of that hypersphere. Then, of this infinitely thin spherical slice, you’ll have to further specify the position using X and Y. So, to rotate a point within a 4D hypersphere, you might first rotate it in in Z (specifying the slice), then in X (specifying the latitude) and lastly in Y (specifying the longitude). Since I find the order Z->X->Y to be particularly unsatisfying, I decided to change it to X->Y->Z because everything we’re doing here is arbitrary anyways.

So there you have it. If you haven’t read my devlog on quaternion pairs (and, chances are you haven’t, because nobody really sees or cares about my stuff anyways), let me summarize something for you: Rotation order was the bane of my existence for the longest time, because I could not get over how weird it made everything feel; and the workarounds, up until I finally figured out quaternion pairs, were…hacky, to say the least. But…now, I’m, of all things, deliberately adding it back in!

And after playing around with it for a little, it turns out that it’s not actually that difficult, it is just indeed a little unusual at first; with some practice you can manage to look at objects more or less fine. Plus, the addition of quaternion pairs (should I just call them “quatpairs” from now on? Honestly, I kind of like that term.) allows for so much more flexibility than before.

Note that this implementation still has its fair share of issues and bugs, so I’ll be seeing what I can fix soon enough; though I have a different priority as of right now (the 4D video), and this is just something I couldn’t get my mind away from. Even though I doubt a single one even exists, a small heads up to those lurkers that are interested in my stuff but not quite enough to build up the courage to leave a comment and say hi: I am putting the 4D blog on hold right now because I instead got a different idea to help me get my project out there a little, which is a YouTube video about 4D.

The past couple of days I’ve been working on it a lot, though most of this work has gotten into writing my own system to make visualizations (I’m calling it the AnimatedStateMachine if you’re interested, and I actually really like what I cooked up here), but I have written the script and done a few visualizations already. I know there’s stuff like Manim out there, but I not only didn’t feel like learning a new tool, I also wanted to write my own Unity implementation, especially because I have written the 4D project in Unity already and figured it might be useful to have both in the same place. And because… what game developer is a game developer that does not feel compelled to reinvent the wheel for every little thing?

Provided I have time to finish the video (21 days left until the deadline…), I would love to make this video a SoME4 submission. I hope that this would help me reach at least a little bit of an audience, as I know from experience that YouTube’s algorithm seems to resort to rolling dice at times. Though >1k views would be nice, I think it’s a better idea to not have much of any high expectations of it, as despite how few people care of it I do not want to give the dream of a true virtual four-dimensional world using perspective projection up at any cost.

There’s something nice about writing something here and knowing nearly nobody will know about it for the longest time…just for some guy in a couple of years to randomly stumble upon it while researching for their master’s thesis in mathematics or something. And if that guy is you, then… hello! Thanks for stopping by, even though it might be painfully obvious that I have no background in mathematics, I still hope you got something out of my yapping! If an 18 year old informatics student can, even when a lot of pain and misunderstanding is involved, figure out some of the basics to making a four-dimensional rendering system, I believe you can do whatever you’ve set yourself out to do as well!

I have so many plans for all of this. I want to make a 4D game, one that explains how it all works, maybe with lighting, collissions, a physics engine… It’s a multi-year project. However, all of my plans essentially boil down to “remake stuff that people have already made for 3D but in 4D”. I think it’s quite disappointing to see so many talented people making games that allow you to take a 3D slice out of a 4D world, because that, despite admittedly being easier to explain, takes, in my opinion, most of the beauty of 4D away. 4D is not some “mathematical, impossible to think about” thing, it just requires a good amount of re-thinking what your intuition has been hiding from you.

I definitely went a little bit off the rails while writing this. But I like writing. Getting my thoughts out there, even if just for myself, while simultanously doing clickety clackety on a keyboard? It’s great. I think this is the best way to practice typing, write about what you want, what you made, what interests you, whatever… No limits out there in the world of the internet. I love that.

[i am admittedly considering renaming my “Rotation4” class to “Quatpair” because it’s a fun term and i guess it makes sense kinda since you can basically use them like single quaternions…]

Files

a2-2-0_webgl.zip Play in browser
87 days ago

Get 4D Simulation

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.