filmov
tv
Let's remove Quaternions from every 3D Engine: Intro to Rotors from Geometric Algebra
Показать описание
To represent 3D rotations graphics programmers use Quaternions. However, Quaternions are taught at face value. We just accept their odd multiplication tables and other arcane definitions and use them as black boxes that rotate vectors in the ways we want. Why does i^2=j^2=k^2=−1 and ij=k? Why do we take a vector and upgrade it to an "imaginary" vector in order to transform it, like q(xi+yj+zk)q∗? Who cares as long as it rotates vectors the right way, right?
Personally, I have always found it important to actually understand the things I am using. I remember learning about Cross Products and Quaternions and being confused about why they worked this way, but nobody talked about it. Later on I learned about Geometric Algebra and suddenly I could see that the questions I had were legitimate, and everything became so much clearer.
In Geometric Algebra there is a way to represent rotations called a Rotor that generalizes Quaternions (in 3D) and Complex Numbers (in 2D) and even works in any number of dimensions.
3D Rotors are in a sense the true form of quaternions, or in other words Quaternions are an obfuscated version of Rotors. They are equivalent in that they have the same number of components, their API is the same, they are as efficient, they are good for interpolation and avoiding gimbal lock, etc... in fact, they are isomorphic, so it is possible to do some math to turn a rotor into a quaternion, but doing so makes them less general and less intuitive (and loses extra capabilites).
But instead of defining Quaternions out of nowhere and trying to explain how they work retroactively, it is possible to explain Rotors almost entirely from scratch. This obviously takes more time, but I find it is very much worth it because it makes them much easier to understand!
For example, Quaternions are introduced as this mysterious four-dimensional object, but why introduce a fourth dimension of space to visualize a 3D concept? By contrast 3D Rotors do not require the use of a fourth dimension of space in order to be visualized.
Trying to visualize quaternions as operating in 4D just to explain 3D rotations is a bit like trying to understand planetary motion from an earth-centric perspective i.e. overly complex because you are looking at it from the wrong viewpoint.
It would be great if we could start phasing out the use and teaching of Quaternions and replace them with Rotors. The change is simple and the code remains almost the same, but the understanding grows a lot.
As a side note, Geometric Algebra contains more than just Rotors, and is a very useful tool to have in one's toolbox. This article also serves as an introduction to it.
0:00 Introduction
2:30 1.1 - Rotations happen in 2D planes
3:09 1.2 - Explicit Sense of Rotation
3:36 2.1 - The Outer Product
4:26 2.2 - Basis for Bivectors
4:41 2.3 - 2D Bivectors
6:17 2.4 - 2D Bivectors from non-unit vectors
6:54 2.5 - 3D Bivectors
8:15 2.6 - Semantics of Vectors and Bivectors
9:01 2.7 - Trivectors
9:42 3.1 - Multiplying Vectors together
11:48 3.2 - Multiplication Table
12:15 3.3 - The Reflection Formula (Traditional Version)
12:55 3.4 - The Reflection Formula (Geometric Product Version)
13:32 3.5 - Two Reflections is a Rotation: 2D case
14:26 3.6 - Two Reflections is a Rotation: 3D case
15:03 3.7 - Rotors
15:35 3.8 - 3D Rotors vs Quaternions
Комментарии