3 ms·
For anyone who hasn't been exposed to this problem before, like me, there are countless applications for this sort of mathematical operations in game developmen
by gravypod 10y ago
For anyone who hasn't been exposed to this problem before, like me, there are countless applications for this sort of mathematical operations in game development.
Back a few years ago a friend and I were attempting to write a game engine. We hit many road blocks but what often killed us was fixing gimble lock. This isn't an issue for many things like FPSs or side scroller but when you get into the realm that we wanted to tackle (first person space flight) it becomes a challenge.
Quaternions, from my position as the ultimate laymen, take up the slack that Euler coordinates/angles have. The issue comes from rotating an object. Once the object is upside down, it's coordinate system stops working as you would expect. If you are head-to-floor upside down then your up relative to the world is down. When applying rotations that are based on shifts in pitch, yaw, and roll it is difficult to have correct behavior.
If instead of this, you implement quaternion rotations for all objects, this entire class of headache melts away. The problem is finding a good explanation of how this works or even yet how to implement it. It's what's stopped me dead in my tracks many times as the implementations often available still have many bugs (when in Space Engineers if you rotate your cursor a circle quickly you'll slowly rotate your character, this is a common bug in many implementations I've found)
I'm definitely going to read through all of this when I get back from uni today.
PS: Mathematicians/dark arts practicers, if I'm incorrect about anything I've said here please let me know and point me to where I can learn more
- devbug 10y agoHow familiar are you with the complex plane? It helped me a lot to be explained quaternions starting from the complex plane. More specifically, by constructively inspecting their properties. There's a great interactive article that gets the pedagogy of teaching such a complex concept (pun definitely intended). Unfortunately, I can't seem to dig it up. I recall the author's blog using all kinds of CSS and/or WebGL trickery to make 3d backgrounds – anyone know which blog I'm referring to?
- kalid 10y agoSteven Wittens: https://acko.net/blog/animate-your-way-to-glory/ https://acko.net/blog/animate-your-way-to-glory/ https://acko.net/blog/animate-your-way-to-glory-pt2/ https://acko.net/blog/animate-your-way-to-glory-pt2/
- gravypod 10y agoI'm in no way informed about any of the dark arts, or as others call them "mathematics" Any reading will be helpful. Hope someone knows what you're referring to.
- santaclaus 10y agoIsn't there some theorem stating that all 3 coordinate reps of rotations in R^3 have a singularity? But bumping up to 4 coordinates (or 9 if you like rotation mats) eliminates the singularity. Edit: seems kind of like latitude and longitude. At latitude + or - 90, all longitudes map to the same point so that coordinate has no information.
- chombier 10y agoYes, R^3 and the rotation group SO(3) are not homeomorphic (they have different topologies), meaning you can not cover SO(3) with a single chart. So any representation of rotations by 3 numbers is singular somewhere.
- vvanders 10y agoYup, quaternions are also at the root of any good skeletal animation system as you won't find a better/faster way to do pose/animation blending/interpolation.
- munchbunny 10y agoI don't think the Space Engineers thing is actually a bug, as opposed to just a counter-intuitive behavior. In the general case Euler coordinates work much closer to our intuitions about rotation and orientation because the world we live in has a well-defined "down," as defined by gravity. Thus if you have a fixed "up" direction for the "camera", then any point on the sphere has a single corresponding orientation as long as you're not actually looking up/down (analogous to gimbal lock). This has the property that no matter what path your mouse takes, if you return to the same point, you will be oriented the exact same way you started. This is not true with accumulating rotations in general. Try this with a paper airplane: 1. Hold it in the "flat" position at eye level and imagine the x, y, and z axis so that the x axis points out to the right, y points up, and z points down the tail and into your eye. 2. Pitch it 45 degrees nose up (counter-clockwise about the X axis). 3. Adjust your own perspective so that even though the plane is pitched up relative to the ground, you're looking at it as if once again x points right, y points up, and z points into your eye. 4. Now in this perspective, turn 45 the plane degrees counter-clockwise about the new Y axis. Note that this is not the same as "yaw", because new the Y axis you're using is actually 45 degrees off vertical from step #2. 5. Now without rotating the plane, reset your perspective. Notice how in addition to having pitched up and yawed left, your paper plane has also rolled slightly relative to the ground. What you see in Space Engineers is probably this exact phenomenon. It's not so much a bug as it is a side effect of trying to come up with an intuitive rotation scheme when there is no "up".
- mturmon 10y agoThe phenomenon of gimbal lock can provide some intuition: https://en.m.wikipedia.org/wiki/Gimbal_lock https://en.m.wikipedia.org/wiki/Gimbal_lock