Let's remove quaternions from every 3D engine (2018)
marctenbosch.com
marctenbosch.com
I worked in a game engine where a pair of mathy programmers fell in love with Geometric Algebra, and use this same argument that quarternions ought to be replaced to overhaul all of the math code in the engine using Geometric Algebra. The character rigging system removed matrices and used GA instead.
This caused several large problems in the code base:
For one, it slowed the code down a little because the GPU interface is all matrices, so there were conversions to matrices all over the place, rigging in particular.
And only two guys in the studio knew Geometric Algebra, and they didn’t invest time in teaching it or helping people understand it, they just hoisted it on everyone. All the rest of the programmers knew matrix math but not Geometric Algebra, so they would end up avoiding touching any of the GA code, i.e., any code that dealt in transformations. The two guys ended up with a lot of support of their own creation, but they were short with their answers, in part because they got so many questions, so the problem never went away.
The third problem is this whole rewrite was unnecessary. Fixing gimbal lock with quaternions is a tiny corner of the game engine, whereas using GA throughout is a massive rewrite. Matrices work really well for 98% of the code, and it’s not really a huge problem to have one or two routines that convert to quaternions and back while they do a rotation. It is a problem when any transform at all involves bivectors and rotors and you have no idea what the hell those are nor do you have time in your schedule to take a math class at work.
Personally, I’m intrigued by GA and have wanted to learn it for a while, but having used it in production, I’m mildly against replacing quaternions with GA, and very wildly against replacing matrices with GA.
The problem with what they did, and what this article is doing, is suggesting we “fix” something that takes 2 or 3 math classes to understand by replacing it with something that takes an entire semester to understand.
I honestly believe that GA has insights to offer, but I don’t believe it will save any time to upgrade the use of quaternions in any 3d engine.
Time spent -- You're probably right. For new technology, it's probably worth the research to see if code clarity is worthwhile...
The major proponents of GA don't suggest doing this. I'm not an expert so I can't rule out the possibility that somebody, somewhere has done it successfully. Computer implementation of GA is still a research topic: http://geometry.mrao.cam.ac.uk/2016/11/ga-2016-lecture-7/
There is a very strong flavour in the computational GA literature of directly implementing the GA operations—not translating to vector algebra. jessermyers is expressing a minority opinion when he says "don't do that".
Finally (and this might be a bit rude) I'm dubious about your assessment of your coworkers fluency in GA. Maybe they seemed totally facile with the bits they knew. In general, though, non-speakers can't assess fluency (in any language, right?). Similarly, what are you actually saying when you say that you "believe" GA has insights to offer? What is that confidence/assessment based on?
Applying GA is an active research field—it's not something people attain practical mastery in, just yet.
Similar to how electric engines are superior to ICE in many ways, but ICE has a century of optimization work already done to catch up to.
From my gloriously irrelevant position in this arm chair, I wonder whether there's enough extra oomph that comes from GA to justify the conversion cost and catch up to the existing optimized linear algebra environment.
In fact, the datapoint here is an argument against implementing GA in its general form to perform computations.
There is a world of difference between understanding the properties of a computation and wanting to turn a wrench.
I wouldn't call that rude so much as you making incorrect assumptions and jumping to conclusions on top of my story that is incomplete on details. It certainly would be better left out of your comment, as there's nothing to be gained from cross-examining my ability to assess whether they knew more GA than I did. They did, in fact, know more GA than I did. And while I'm framing myself as a GA noob, I've dabbled enough to know a bit about what I don't know.
> it's possible to use GA as a language for describing geometric operatiins while continuing to implement them under the hood using old-fashioned vector algebra.
You're missing my point. They did implement GA using linear algebra. They built classes for bivectors and rotors that use dot products and cross products under the hood.
Once there are classes for GA objects, and they get used in the code, then everyone else has to use them and know how to use them. You can't use GA without knowing the algebra of GA types.
The implementation of the GA objects is not the question here at all.
Huh? I thought quaternions don't have any problem with gimbal lock. That's a problem with Euler angles and matrices.
Edit: I think you meant using quaternions to fix gimbal lock problems with matrices, which makes sense.
Just look at something like a 50 year old IBM mainframe vs. the newest Sql Server with .Net Core running on the server of your choice. Is the latter the better choice for a new application? Yes. Yet many very successful businesses don't replace their mainframes because the benefits do not justify the costs.
You can represent a lot of algebraic objects and operations using matrices and linear algebra operations. The most accessible example of that is probably complex numbers: https://en.wikipedia.org/wiki/Complex_number#Matrix_represen...
and I wouldn't say that "matrices are still required in complex numbers" any more than I'd say "matrices are still required in geometric algebra".
So using that kind of thinking, the cross product of two column vectors is a row vector: https://www.youtube.com/watch?v=BaM7OCEm3G0
As you say, Geometric Algebra doesn't talk about row vectors and column vectors. For example, in 3D GA,you can choose a representation in R^8. That's 1 scalar, 1 pseudo-scalar, 3 column-y components, and 3 row-y components.
The problem is that all libraries, drivers, etc. use matrices, quaternions and vectors. So you would have to constantly convert back and forth, which is both error-prone and a non-trivial performance problem.
Of course, you could build your own libraries for everything, but that's just crazy. Who has time for doing that?
Not to mention that writing a mathematical library like that is a highly non-trivial task. Not just the algebra part but also numerical stability and accuracy are a big deal. That requires a very skilled person, naive implementations will rapidly blow up in your face.
And doing all this what for, exactly? So that the GA explanation of rotations doesn't require 4 dimensions while the math complexity of rotor algebra ends up being the same as with quaternions? So there isn't really a performance benefit neither.
Quaternions came into favor to solve the problem of gimbal lock in composed Euler rotation matrices. This happens when you create a rotation which rotates one axis into another, and end up with a matrix that loses one axis (it loses an eigenvector), and you become "trapped" in the new rotated frame and can't ever rotate out of it. Quaternions don't suffer from this problem, but they're also tricky to work with and reason about, and their rotations can become funny when composed - instead of rotating from orientation A to B, they'll go through a C in a very different place. You need to create heuristics to keep rotations looking sane with quaternions. In the games that I've worked on, we took other precautions to avoid gimbal lock in rotations and stuck to Euler matrices. For example, in a flight simulator, you always computed the final rotation matrix for the plane location directly from its heading, pitch and roll, and so, you'd never suffer gimbal lock.
Why stick to Euler matrices and not some better Geometric Algebra or Quaternions? Because it's really easy to interpolate, and think about plain old rotations about a vector, and you can teach anyone to avoid gimbal lock. It's easier to avoid that problem than to train a bunch of junior engineers on higher level math.
Quaternion interpolation works well, but it introduces twist, which is sometimes not what you expect. When you start composing many quaterions, you get some wild rotations, going the long way, or doing an additional 360 twist, and whatnot. Mind you, I'm digging 20 years back in my brain here, I don't remember many specifics anymore.
First, because of IK, we cannot control orientations exactly. Newer techniques like motion matching/IK can generate new orientations on-the-fly, depending on what a character is doing and the character's environment. Gimbal lock matters for camera movement as well. Looking up with Euler angles is a great way to induce a seizure if not done correctly.
Second, the "wild rotations" you mention has a very simple solution employed by every engine I've worked with. Basically, you just constrain the real part to be positive which fixes your interpolation on one half of the Lie-manifold which ensures the arc taken is as short as possible.
Matrices and Euler angles are both horrific to interpolate.
It's interesting to compare disciplines, since I've never worked on a game engine but have done a lot of simulation of physical systems: there, quaternions have been standard for at least fifteen years, and I've seen geometric algebra frequently for about the past five.
Interestingly, where we saw most gains from thinking about geometric algebra wasn't in simple rotations, but when starting to look at things like computing kinematic chains composed of dozens of joints: Now we're at 4x4 matrices to store each transformation, which is the traditional way and works well. From this, some seriously deranged mathematicians introduced the concept of an eight-element dual quaternion (essentially, pair of quaternions specially constructed) that can represent this. Again, super efficient, but even more intractable for newcomers than quaternions. At this point, starting to express both concepts in terms of geometric algebra has been able to keep most of the performance improvements as well as only having to teach one concept.
When I left that position a year ago, we were starting to see recent graduates that already had pre-exposure to geometric algebra concepts before even starting to work on the codebase.
That said, taking your argument to the extreme, we all probably should've stuck with PHP, since everyone understood it and, well, was it really worth the switching cost? Naturally that's dumb, so there's a certain amount of "how do we get there?" with any new technology that's probably a good idea.
That's probably not going to get answered by the principal engineer who says This Tech Is The Future. It's going to get answered by people like you who think about switching costs and the impact new tech has on people.
There are multiple paths for honing a new technology, without dumping it on a large group of developers while it's in its experimental stages:
- Use it for a series of side-projects
- Use it in a startup or startup-like team in which all the developers are bought into it, and happy to work through the obstacles
- Use it at an organization that's both able and willing to devote a large amount of resources to making it work (e.g. devoting a full-time team to its development & support & related training)
Once the kinks have been sufficiently worked out in one of those contexts, and a solid ecosystem with good documentation exists, then there's a much better chance that the benefits will be worth the switching costs for the average project.
I imagine AAA games are similar. You have 4 years and ship one monolithic game. Maybe you could prove out this idea in a small area like artist's tools or an engine fork (similar to the approaches above). Trying to incrementally adopt something would take 2 or 4 games (10+ years) and I just don't see technology roadmaps like that. Especially if it's not a huge win.
Very fancy and neatly structured code but in the end you accomplish pretty much the same; and now nobody on the team understands a bit about what you're doing.
"Why would we use a framework that nobody understands but you, to accomplish the same stuff a few SQL statements can do?"
The former option never wins.
Whats going on here is you're scoffing at something you don't understand. Before you scoff, understand it. Then scoff. Until then you're just as good as the ignorant people who ridiculed the theory of a heliocentric solar system.
CT brings nothing new to the table in terms of "now we can do X that we couldn't do otherwise". If you can provide an example to prove its usefulness, please do. Funny thing is that every time it comes down to "just show me" the hand-waving and "you wouldn't get it" begins. Things that work speak for themselves.
>you're scoffing at something you don't understand Actually ... I was also very excited by the promise of CT a few years ago and since then I have read a lot about it and I'm quite confident "I understand" what I'm talking about. I've been programming for about 20 years, half of them with functional languages (or languages with first-class functional constructs: lisp, haskell, scala). I have read the most famous books on CT touching on programming, some of them are signed as I have spent my own money going to some CT conferences and meeting with the people there.
As a conclusion, I don't mean that CT is useless in itself. It definitely is a nice mathematical framework and has proven a great tool for a few things here and there in different areas of math. But in the context of computer science, as I said it before, it does not bring anything new to the table.
You mean that in the "all Turing complete languages are the same"? Because I can't make sense of it with another meaning.
If so, you can keep writting web applications in assembly, I guess it's comfortable using something you already know.
One example where CT helped me.
He's scoffing at something he doesn't understand. That is 100% ignorance.
This is entirely different from scoffing at something over complicated and that you do understand.
And if you mean dahart, he said (or at least implied) that he didn't understand geometric algebra, but he didn't say anything about understanding category theory.
Clearly his subsequent post says he does understand CT so I'm in error on that part.
Either way the "team" not understanding it, does not preclude it from being right. CT does not overcomplicate things. It just allows you to understand a program differently so you can decompose your program into smaller pieces or take a different path.
Saying CT complicates things is like saying number theory complicates numbers. Number theory is numbers and CT looks very much like a good theoretical framework for program organization. In other words CT looks like a formal theory for the design of programs.
We aren't at a spot where we can concretely say this, but practitioners of CT and programming are enamored with CT because it looks this way.
Overall, his complaints point to a lack of understanding despite his claim.
>moralestapia never said he didn't understand it. In fact, in a parallel branch of the comment tree, he said that he did understand it. Your post is at best a misreading of what he said, and at worst a deliberate slander.
I don't like comments that accuse me of slander, even as a possibility.
I'm going to be frank with you. HN is a big place with thousands of users, I never encounter the same user twice... but you seem to appear regularly out of nowhere and reply to my comments. I may be wrong and that you happen to be just everywhere but your responses seem like you're just hunting me down to reply to me.
If you are doing that please stop. Additionally I just don't like you or care for your opinions in general because of the above hostility. So even if you aren't creeping around just to reply to my comments, I'd appreciate it, if the next time you see my name just ignore the comment and move on. My comments are not addressed to you and they have nothing to do with you.
> ... but you seem to appear regularly out of nowhere and reply to my comments. I may be wrong and that you happen to be just everywhere but your responses seem like you're just hunting me down to reply to me.
Bluntly, I notice you most often by seeing a comment that I think is too harsh of a reply to someone else. I don't like it when I see that. (You complained about me doing so to you, with some justice, so you should understand the feeling.) I try to give you the benefit of the doubt, because I have the impression that English is not your first language. But it seems to me that you often interpret peoples' words in a very negative way, which their actual words do not seem to me to deserve. I get annoyed when people do that (not just you). I try to speak up when I see people getting grief that they didn't deserve (again, not just when you're involved).
> So even if you aren't creeping around just to reply to my comments, I'd appreciate it, if the next time you see my name just ignore the comment and move on. My comments are not addressed to you and they have nothing to do with you.
Post on a public forum, get public replies. If you post here, you don't get to control who can reply and who can't.
I can't order you to back off. But imagine this. You are approaching me every day in a public place and I turn and face you and I tell you to back off. This is the level of threat you are inciting. Your presence is not welcome and the environment is now extremely hostile. I can't call the police on you in a forum but if this were a public place it would be justified.
I am telling you to back off. It's your choice whether you do so, but I ask you to check your actions and really think about what you are starting here.
I find it highly unlikely that you are just coincidentally encountering me all the time out of nowhere. I'm dead serious. I don't like you, I don't care for your comments, back off.
I am not trying to harass you or stalk you. But I'm going to keep reading what interests me. If I see what you wrote and I think it's wrong, I'm going to reply. If that upsets you, I'm sorry that you're upset, but I do not consider that reason for me to change what I read or who I reply to.
The one thing I can offer is that I will try to be careful not to over-react when I reply to you. I'll try to be careful to be moderate in my words.
> I can't call the police on you in a forum but if this were a public place it would be justified.
Even here, you can email dang if you think I'm seriously out of line. Feel free to do so if you think it's justified. I'm completely serious. If I actually am at fault, I easily may fail to see it in myself. If dang thinks that it warrants telling me to back off, I will take that very seriously.
>If dang thinks that it warrants telling me to back off, I will take that very seriously.
Are you serious? The person that is feeling harassed is telling you to back off and you are getting in his face and saying let dang decide? I don't think you're serious if you are actually inviting me to escalate this issue. If you reply to any one of my other posts I definitely will request his aid to moderate. BACK OFF.
Wow.
D3D API exposes a way to pass constant buffers to shaders. You can pass whatever you want there, even integers. There're couple limitations, size must be multiple of 16 bytes, and can't exceed 64kb, but I don't remember anything specific to matrices.
Now, the only place I can remember which specifically targets matrices - mul intrinsic in HLSL. But that thing is just a syntactic sugar, usually compiling into dp4 dxbc instructions.
Two years ago, my wife asked me, "If you had to get a math equation tattooed on your body, what would it be?" I answered, "i^2 = j^2 = k^2 = ijk = -1".
I felt a brief flush of anger when I saw this headline.
This is an extraordinarily good article that should be read by pretty much anyone doing graphics programming.
You're like this Irish bridge that has the notation inscribed on it as well.
I would like to own an OpenGL kettle with the expression on it.
Do you mean the Utah Teapot?
Kettle and teapot are synonyms as far as I'm concerned.
You pour the boiling water into a teapot, usually made of ceramic, which holds the tea leaves.
Not that it's important, but now ya know.
A kettle is used for heating water. In earlier times, it was made out of metal and put onto a heat source (fire, stovetop). Nowadays it is almost entirely displaced by the electric kettle, which is commonly made out of plastic and contains a metal heating plate or spiral on the inside.
A teapot is a ceramic pitcher where you put the boiling water and tea leaves to brew the tea.
Definitely a kitchen gadget I'd recommend to anyone.
If anyone's curious the story is here: https://en.wikipedia.org/wiki/Utah_teapot
Could you explain why? For someone without a math background, it seems indeed like a pretty arbitrary thing to define.
(I can understand the idea behind complex numbers and how the multiplication rules followed from the desire to define the square root of a negative number - however, so far, I don't get the motivation of introducing even more "special" elements)
As for why one might want to consider such a noncommutative division algebra in the first place, the answer I suppose is just that it manages to pop up in a variety of areas in mathematics. We've already seen the connection with rotations in 3-space (the topic of this post). Here's another. The 3-sphere (that is, a sphere in 4-dimensional space whose surface is itself 3-dimensional) can be realized as the multiplicative group of unit quaternions spanned by {1,i,j,k}. Consider the circle H = {cos(theta) + i * sin(theta)} for real values of theta; H is a subset of the 3-sphere. If r is any unit quaternion, then the coset rH is another circle. But given a subgroup H of any group G, the left cosets of H in G form a partition of G. Therefore, these circles just described form a partition of all of the 3-sphere (the Hopf fibration).
Speaking of rotations, the involvement of quaternions should not be surprising. Indeed, complex numbers are intimately involved in rotations in 2-space (multiplication by a unit complex number e^(i*theta) corresponds to rotation about the origin by theta). Quaternions can similarly express rotations in 3-space, but one cannot just left- or right-multiply but must instead use conjugation. In general, one can generalize this using the techniques of geometric algebra.
[1] https://www.quantamagazine.org/the-octonion-math-that-could-...
That's a bit reductionist. You don't just get the square root of a negative number, you get the Fundamental Theorem of Algebra (an Nth degree polynomial has N roots), which is a mathematical power tool if ever there was one.
Complex numbers dramatically simplify a bunch of proofs in linear algebra, give us tons of nifty integration techniques in complex analysis (the techniques are relevant for real numbers, they just use C), provide a representation of 2D rotations that can be manipulated using the rules of algebra (this is the most relevant to the thread), and give physicists, electrical engineers, and signal processing people an abstraction to represent oscillations (energy sloshing between two buckets = two elements of a complex number, which you can then do algebra with). They're a workhorse.
Quaternions are an attempt to do that in 3D. The dot and cross product of vector calculus are other pieces of those efforts. Unfortunately, vector calculus escaped the "math lab" before it was complete and got written into other fields and engineering books, so even though the underlying concepts were eventually sorted out (it's called Geometric Algebra), everybody just uses the half-baked abstractions (quaternions, dot product, cross product) which are Good Enough. It's a perfect example of "worse is better" affecting something other than software engineering.
I guess the question is, why does it then stop. Why not a 4D alternative. Or if you look at it going by scalars needed in a single value, it goes from 1 to 2 to 4. Why not 8 or 16 (or some other growth)? Why does it stop there?
Also, is there as easy of a problem to understand introducing the 3D technique (be it quarternions or be it Gemoetric Algebra) that works as well as using sqrt(-1) for imaginary numbers?
16 https://en.wikipedia.org/wiki/Sedenion
32 https://arxiv.org/pdf/0907.2047.pdf <- Trigintaduonions
Geometric Algebra can capture the structure of both complex numbers and quaternions, and also the structure of the dot products, cross products, and the different kinds of vectors that arise from those operations.
To be clear, matrix multiplication can also capture the structure of complex numbers [1] and quaternions [2]. There might also be a concise reference to matrix representations of some geometric algebras, but I didn't find one. So matrices are kind of one way to not "stop at 3D", but the structure is almost too uniform (which on one hand makes it too general, and on the other hand makes it not general enough), I'd say). Sure, with a matrix you can represent rotations in 4D, but you still need to operate on vectors only. Geometric algebra, if it does have a matrix representation, gives names to special kinds of matrices and special kinds of vectors.
[1] https://en.wikipedia.org/wiki/Complex_number#Matrix_represen... and [2] https://en.wikipedia.org/wiki/Quaternion#Matrix_representati...
It doesn't stop. That's what motivated geometric algebra, which works in any dimension. Quaternions are a sub-algebra of geometric algebra. They represent 3D rotations, which makes them interesting in their own right.
Asterisk: I believe there's a sign convention issue in mapping between quaternions and the even subalgebra of the 3D geometric algebra, so they aren't identical, just isomorphic.
> Also, is there as easy of a problem to understand introducing the 3D technique (be it quarternions or be it Gemoetric Algebra) that works as well as using sqrt(-1) for imaginary numbers?
That's an extraordinarily high bar. I don't believe anything reaches it. Part of the problem is that complex numbers are one of the most successful concepts in all of mathematics. The other part of the problem is that most of the useful facets of geometric algebra escaped the field of abstract mathematics under their own name before the unifying structure was discovered. The dot and cross product, quaternions, differential forms and the general Stokes' theorem are all examples. The remaining value proposition of geometric algebra lies mostly in getting rid of minor annoyances that come from this half-baked nature of traditional vector calculus tools:
* Cross products break in more than 3 dimensions and they break if you reflect them (see: pseudovectors). Bivectors have no such issues. They represent rotations in any dimension, reflected or not.
* Vector algebra with dot and cross products involves memorizing lots of new identities and applying creativity to work around the absence of division, while geometric algebra just has division and the same bunch of algebra tricks you already know. The geometric product isn't commutative, so it isn't perfect in this sense, but learning to deal with non-commutative algebra is a much more fundamentally useful thing than learning a bunch of 3D-specific identities.
* Dot and Cross with one argument fixed "destroy information" mapping from their input to their output. If you put them into an equation, the equation does not fully constrain the free vector, so you are often going to need more than one equation to represent any single geometric concept. Not so with geometric algebra. Many concepts map to a single equation. Including Maxwell's Equation (I use the singular intentionally)!
do you have a good reference for this? i've looked into GA bit but don't remember seeing anything like this. e.g. what would dividing a bivector by a vector mean?
Thankfully, this is a solved problem. The correct generalized structure for doing geometry is called a Clifford algebra. For n-space and any nonnegative integers p,q satisfying p+q=n, there is a corresponding real Clifford algebra Cl(R,p,q). Cl(R,0,1) turns out to be isomorphic to C (the complex numbers), and Cl(R,0,2) is a four-dimensional algebra that turns out to be isomorphic to Q (the quaternions).
This is actually not that surprising, because the signature (p,q) more or less means the algebra is built by adjoining p generators that square to +1 and q generators that square to -1 in the base field. This is formalized by taking a quotient of the tensor algebra of the field. You might wonder though why we have (p,q) = (0,2) for the quaternions. That's because if the two generators that square to -1 are i and j, then we can build the third as k = ij, so we get it for free.
A real Clifford algebra is known as a geometric algebra, and these give rise to objects called rotors. Rotations in an arbitrarily high-dimensional space can then be written as conjugation by a rotor.
His carving, if it ever existed, is gone. But there is a plaque on the bridge commemorating the event. It reads:
Here as he walked by on the 16th of October 1843 Sir William Rowan Hamilton in a flash of genius discovered the fundamental formula for quaternion multiplication i² = j² = k² = ijk = −1 & cut it on a stone of this bridge.
Its one of the only maths history books I couldn't put down.
I got to the point where I needed to cite an original source for the quaternion equations, so I cited the bridge.
He got the message.
1. Complex numbers have associativity and communitivity of multiplication. (That is, (ab)c=a(bc) and ab=ba).
2. Quaternions have associativity but not communitivity.
3. Octonions have neither.
4. Sedenions [2], trigintaduonions, and not associative, commutative, nor even alternative [3]. (Alternative is associative specifically when the middle value is equal to one of the other's; i.e. a(ab)=(aa)b.)
[1] https://en.wikipedia.org/wiki/Cayley%E2%80%93Dickson_constru...
Why do I like it? I am, as klodolph notes [1], a dyed-in-the-wool algebraist. It's where I find the most beauty and joy in mathematics.
[1] https://news.ycombinator.com/item?id=22202606
This invention/discovery is a fundamental development in abstract algebra, not a terminal one. Quaternions are just a jumping-off point, and I've always found the Caley-Dickenson construction that pauldraper explains[2] absolutely beautiful.
[2] https://news.ycombinator.com/item?id=22202513
Why would I want it specifically as a tattoo? jfengel points out the special history of that specific equation[3]: it was (allegedly) carved into a bridge in Dublin when Hamilton stumbled onto it, but the carving is gone. Kinda fitting to give it new permanence.
[3] https://news.ycombinator.com/item?id=22202513
So, putting it all together: it's a fundamental development in abstract algebra, which is my jam. It's could have been permanently inscribed in a bridge, but that's been lost to time, so giving it new permanency seems fitting.
Also, it's practical. My first thought was actually the Cayley table for the Klein four-group[4], but that would be a lot harder to get tattooed in a nice visible way. How I went from there to Hamilton's quaternion equation is left as an exercise to the reader. (If you're new to Cayley tables, they're just fancy times tables. Replace "e" with 1.)
[4] https://en.wikipedia.org/wiki/Klein_four-group#Presentations
And Euler's formula is about rotations in a 2D plane and the way complex exponentiation describes it.
This looks like it loses important information ?
picking one up to unique isomorphism should be good enough ;)
If I had to get a math tattoo, I think I'd go for lim n→∞ Q_n^(1/n) = e^(ᴨ^2/(12 log 2)).
That comes from a theorem proved by Khinchin and Lévy. Khinchin proved that for almost all real numbers if you take the sequence of convergents of their continued fraction expansion, {P_1/Q_1, P_2/Q_2, ...}, then the sequence {Q_1, Q_2^(1/2), Q_3^(1/3), ...} approaches a limit, which is the same limit for almost all real numbers. Then Lévy determined the value of that limit, which is now called either Lévy's constant or the Khinchin–Lévy constant.
If not that, then this (in standard math notation rather than the verbose notation I'm using here):
Line 1: Let H_n = sum i=1 to n 1/n
Line 2: Hypothesis: sum d|n d < H_n + e^H_n log(H_n) for all n > 1
That's neat because that hypothesis is true if and only if the Riemann hypothesis [1] is true [2].
The Riemann hypothesis is a conjecture about complex numbers, and is widely considered to be the most important unsolved problem in pure mathematics. That it turns out to be equivalent to a such a simple conjecture involving just integers and a couple real functions from pre-calculus is a surprise.
A set S of real numbers has measure zero if for any positive ε no matter how small, there exists a countable set of intervals such that (1) every element of S is in at least one of the intervals, and (2) the total length of the intervals is < ε.
For example, let S be the set of positive integers, {1, 2, 3, ...}. Proof: consider the set of intervals {I_1, I_2, I_3, ...}, where I_n is the interval [n-ε/2^(n+2), n+ε/2^(n+2)]. Every member of S is contained in one of these intervals.
The length of I_n is ε/2^(n+1). The length of all the intervals is ε(1/4 + 1/8 + 1/16 + ...) = ε/2 which is < ε.
Thus S, the set of positive integers, has measure zero.
A similar argument works for any countable set of real numbers, such as the rational numbers or the algebraic numbers, and so something that was true everywhere except at rational numbers would by true for "almost all" real numbers.
It can go next to the skeletal formula for benzaldehyde on my imaginary nerd canvas.
> Instead of using this thing you don't understand and investing the time to understand it, why don't you use this other thing you don't understand, and invest the time to learn that instead.
Indeed, later in the article the author says:
> We can notice that 3D Rotors look a lot like Quaternions ... In fact the code/math is basically the same! The main difference is that i, j, and k get replaced by y∧z, x∧z and x∧y, but they work mostly the same way.
Have I got that right?
The pitch in the OP is (I think) intended for people who feel pressure to understand why it works. Geometric algebra can be built up yourself by picturing actual rotations, one dimension at a time. It's physical from the start. Quaternions are a finished math system that you have to reverse-engineer to understand. Some people like one approach or the other better.
Some geometric algebra people are kind of true believers. That's probably not helping the notation get traction.
Why not change? Comfort?
There's some return on all that investment. It might pay off or it might not. I think it's a design decision.
If you would read a few sentences on from where you quote, this becomes evident.
ij = k
is arbitrary, needs to be memorized and just happens to do what you want for reasons that require a lot of working out. (xy)(yz)=x(yy)z=xz
On the other hand requires zero memorization.It's probably my mathematical background speaking, but I find this far from arbitrary. Quaternions don't spring from nothing. It seems to me that (xy)(yz)=x(yy)z=xz needs just as much justification and memorisation ... why should y^2=1?
I guess my point is this. If people put in as much effort to understand quaternions as has been expended in this article, then quaternions would probably be just as easy to grasp and the system being described.
You can treat complex numbers as 2D rotors (a 2D rotor is cos alpha + xy sin alpha, so xy can be replaced with i) and quaternions as 3D rotors. But if you build Cayley numbers from quaternions they don't have the same geometric meaning as 4D rotors.
Some memorisation is required, but it is in terms of things that are easily visualised.
So x² = xx = x^x + x·x = 0 (area) + 1 (length)
xy = x^y + x·y = x^y (unit area) + 0 (length)
What I was saying is that summing areas and length is exactly what happens with vector product. The k vector (or the k imaginary unit in quaternions) is the third unit vector, so it has length 1. But when I compute i⨯j=k, I suddenly interpret it as the area of the parallelogram formed by a and j, and at the same time k is the direction perpendicular to both i and j so its coefficient must be a length.
Likewise for triple product which computes a volume but it expresses it as a number (i.e. a length). We study all of these things in vector calculus and don't pay attention to these inconsistencies, but they are there.
It's even more confusing because the triple product is actually a signed volume (pseudoscalar). I admit that I also never noticed these problems until learning GA.
Having to remember, out of the six possible permutations, that one of the three correct formulas is the one with the symbols in alphabetical order is much better than remembering the "right hand rule" (or was it "left hand rule"?).
x ^ y = x y - y x^T is the generator of the rotation that rotates a vector in the direction y into the direction of x. There is absolutely nothing to remember, and you can work this out immediately from just multiplying out the matrices:
exp(epsilon x ^ y) v ~ v + epsilon x ^ y * v = v + epsilon x (y,v) - epsilon y (x,v)
We add a little bit in the x direction and remove a bit in the y direction.
The whole view of rotations happening round an axis is just a coincidence of 3d space, it doesn't make sense in higher dimensions. On the other hand rotations always do (compose into ones that) happen on planes.
x ^ y = y x^T - x y
exp(ε x ^ y) v ~ v + ε x ^ y * v
= ε y (x,v) - v + ε x (y,v)
because we use the left-hand rule down under.You can do anything you do with our numbers with roman numerals. You could argue that our base-10 system is as arbitrary as roman numerals, or that knowing how to do arithmetic in one system will allow you to do arithmetic in the other one. But that does not mean that learning arithmetic with roman numerals has the same difficulty as with base-10 numbers, and the only reason we find it more difficult is because we do not put enough effort.
I have introduced a few grad students to quaternions and GA. We eventually use quaternions most of the time, but they do not understand quaternions until they see GA (the same as someone may need some base-10 theory before completely understanding roman numerals arithmetic).
y^2 = 1 is because it's a unit vector. The fact that bivectors are the correct way to view rotations is evident if you look at higher dimensions. Bivectors work just the same way as described here when you want to work in R^n, you just add basis vectors beyond x, y, z. But the algebra they describe no longer forms an associative division algebra over the reals. There is no way to get to the algebra of the (generators of) rotations in higher dimensions from the quaternions.
This is why i would say the quaternions (as built up from the complex numbers) are a non-sequitur and incidental to the structure of rotations.
Then again, I would always argue that one should use complex numbers to think of rotations in R^2, so.... :)
That's not so strange, it's basically e^i*theta isn't it?
Geometric algebra also addresses much more than just rotating stuff, it's just that when you want to do rotations it leads naturally to something very similar to quaternions.
He also gives a concrete reason: For 3D objects, rotors operate fully in 3D, whereas quaternions are in 4D. This means you can visualize rotors and imagine "how they work" whereas with quaternions, you have to more or less blindly trust the formulas.
This is a bit of a stretch -- by the same logic any operation on more than three numbers means I have to trust the formulas. We have many methods to understand, visualize, develop intuition, etc. in such cases, such as "fix a, look at what happens when you vary b, c and d". When I am working to understand dynamics of an object with three variables in MATLAB or similar, I seldom (probably never) plot it in 3D (which gets projected on the surface of a flat monitor anyway). Instead I usually play with numerous 2D and even 1D plots. My 2c.
By this, the author means: you can visualize a rotor FULLY in 3D, no extra dimension neccessary.
I suspect you never have tried to think about how quaternions work mechanically, I suggest this neat video:
I do get the theory part -- I know how quaternions and rotors work (and have a PhD in "pure" math). My objection (and a pretty firm one) is with the "if a phenomenon has more than three variables we cannot visualize it" logic. While lower dimensions make things a little easier to understand and develop an intuition for, a convenient abstraction or a model is much more important. Most engineers work with things described by multiple variables all the time and "reduce dimension to three" is seldom the main goal.
If the claim is that rotor is a better model, more convenient for software engineering, we can examine (and debate) that. But we should not recommend switching just because it has one less variable. For someone with an algebraic rather than geometric view, the ability to multiply quaternions on a piece of paper may be a strong benefit. Double-checking, say the result (1+i)*(j-k) by hand takes 10 seconds and a piece of paper; try mentally computing the rotor composition -- you would probably fall back on algebra (I certainly would).
> 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!
I can't speak to his argument really as, when it comes to 3D game dev, I'm purely a hobbyist. I do believe though that in the end, programmers want to program. They want to be handed a library with an API that makes sense. The ones who care deeply about the whys and hows of the math will always take the time to learn it; others just want to know how to write the code. For those people, I'm not sure the rotor equations I saw are any more intuitive at first blush than the quaternion equations.
In short, I feel like by the time you're at the point where you're explaining the details of a topic like geometric algebra, you've likely already lost the people who just want to code, even if the description you provide is more intuitive.
Having said that, I still found the video fascinating.
In this case, a 3D visualisation is the right tool because the problem is all about objects in 3D space. So rotors let you mentally work with the same objects you're thinking about anyway instead of switching to some other concept or representation.
I don't see that "it's technically 2D anyway because it's projected to the surface of my monitor" is a valid argument. My visual system knows pretty well how to deal with pseudo-3D objects, thank you very much.
This is a very interesting point. Have you tried VR? Do you think this preference for 2d and 1d is just because 3d display technology is still inconvenient or is it something deeper than that?
If it means rotors can be used to give a simple formula for rotations in 3D space, then it also applies to quaternions.
If it means the space of rotors is three-dimensional, then it's false: rotors have 4 coordinates, a + b x^y + c y^z + d x^z, just like quaternions.
Does it mean something else? Something that applies only to rotors and not to quaternions?
It's also easy (after reading the article) to understand the operations that can be performed on these things.
It's not as obvious what i, j and k in the quaternions correspond to, or why they have the multiplication table that they do. It's an algebraic construction, not a geometric one and hence more difficult to visualise.
Quaternions and rotors are exactly the same in practice, but the intuitions are very different. The intuition behind rotors involves planes and lines in 3D, whereas the intuition behind quaternions typically involves a unit hypersphere; there's a 3B1B video on quaternions where you can learn more about them.
Note that even if you do restrict q to have unit norm, q and -q still denote the same rotation! (In other words, the space of rotations isn't really S^3, but projective space RP^3.)
I'll be sure to check out the 3B1B video, I keep seeing them recommended and I think they might a good resource to recommend to my students.
Rotors use a.b with aXb, and quaternions use magnitude and 3D direction vector.
Rotations do involve magnitudes when interpreted as an axis (2 dimensional manifold embedded in R^3) and a magnitide (0 to 2pi)
https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representat...
SO(3) is a coordinate-free abstraction that isn't relevant to the topic of GA vs Quaternions for calculating concrete values in computer graphics
Quats are quite easy to reason about: a unit quat holds a rotation about an axis: rotation about angle theta an axis given by direction (x,y,z) is quat q = sin(t/2) + cos(t/2)(xi+yj+zk).
Composing quats q1 * q2 is the rotation you get by applying q2 then q1 to an item.
So think of the scalar as holding info about the angle rotated, and the vector part as the direction of the axis.
I don't see how with rotors or quats you can easily visualize composition or more complex actions (and I've used both extensively). "Blindly" trusting the formulas can be replaced by working through a proof enough times until you feel how they work, just like linear algebra, algebra, quadratic formula, etc.
You can write down Maxwell’s equations using the geometric algebra easily, and it will make them better! They will be obviously coordinate independent.
Pretty much anything with a cross product will be better written using geometric algebra.
One of their main uses is to prove the generalized Stokes theorem in n dimensions.
3D rotors are isomorphic to quaternions, so go ahead and rename your variables :).
So, to be as opinionated as the g'parent comment:
The cross product is a hack which only works in certain dimensionalities, whereas the wedge product is the underlying idea, which works in all circumstances.
To be less opinionated:
The cross product is inconvenient because what it gives you aren't the "usual" vectors, they're axial vectors, which behave differently under mirror reflection than all of your other vectors do.
Whether you call it the cross product or not is just semantics, but it does exist in terms of the exterior product.
It's difficult to find online, but it's constructed directly in Spivak. A quote:
"It is uncommon in mathematics to have a "product" that depends on more than two factors. In the case of two vectors v,w in R^3, we obtain a more conventional looking product, v X w in R^3. For this reason it is sometimes maintained that the cross product. can be defined only on R^3" - Calculus on Manifolds, pg.84
Most graduate students read this (or did five years ago).
I never said the wedge was the only way to generalize the cross product, I just said the cross product itself wasn't general.
We used to think as negative numbers being a generalization of the integers, so that's some food for thought. I'm sure once quantum mechanics dominates solving eigenvalue problems will be a high-school level problem, so we'll end up having complex numbers losing their complexity. We don't call them "real" numbers outside of math circles anymore.
To say that the cross product itself is a hack is a bit of a stretch though, it can easily be generalized and I think it's quite natural.
> We used to think as negative numbers being a generalization of the integers
"used to" ?
> We don't call them "real" numbers outside of math circles anymore.
Sure we do ?
To clarify, we used to think of integers as just the natural numbers. Integer was a colloquial word meaning "whole, entire", so there was presumably a discussion about how negative numbers were whole or entire, though I vaguely remember this historical story. My point is just that at some point negative numbers were seen as a advanced extension of the natural numbers. Even zero was seen as an unnatural extension, which is why there is a confusion to this date as to whether "natural" numbers include zero.
ref: http://mathforum.org/library/drmath/view/57212.html
Not the best reference, but I've read it elsewhere, so maybe it's a myth, but someone can trace it to the source if they want.
> We don't call them "real" numbers outside of math circles anymore.
I mean laypeople don't know what the real numbers are in distinction to the rationals, for example.
Then again, with these conversations, the N < Z < Q < R < C... classification automatically pops in your mind if you did mathematics in last classes of high school (that's going to be a LOT of laypeople ! Of course, a lot of them, those that rarely encounter them, might then forget about this classification.)
And integers are still called "natural integers", and negative numbers are NOT called "natural" ?
"Even Prof. Willard Gibbs must be ranked as one of the retarders of quaternion progress, in virtue of his pamphlet on Vector Analysis, a sort of hermaphrodite monster, compounded of the notations of Hamilton and of Grassman"
See "History of Vector Analysis" by Crowe or "Hamilton, Rodrigues, and the Quaternion Scandal" by Altmann. Nice to see the author cites these!
The Geometric Algebra comes from Clifford Algebras, which where an attempt to combine Hamilton's Quaternions and Grassmann's forms, and in fact contains both as sub-algebras. In the case of 3D rotations calling them Rotors or Quaternions seems mostly like a different way of thinking about the same thing.
I think this would be more kindly put as "reimagining" quaternions and not "removing" them. The additional geometric intuition from GA does seem useful, and even as someone who has used quaternions extensively (though in a very different context), I would also choose to work with Geometric Algebra as a framework for geometry over Quaternions.
The visualizations are quite good here, it is a good way to understand bi-vectors, you can wiggle them about a bit in 3D instead of just staring at parallelograms on a page. The only criticism I have is that they say quaternions and the cross product come "out of nowhere", but then the way they present the geometric product is equally "out of nowhere".
[1], a point at the origin, is the same as [1 0] - a point at the origin in 1 dimension, or as [1 0 0], a point at the origin in 2 dimensions, or [1 0 0 0], a point at the origin in 3 dimensions.
Similarly, [0] is a zero vector. [0 0 0 0] is a zero vector in 3 dimensions.
Having to know [0 0 1] is a point at the origin in 2 dimensions (with a homogeneous coordinate), while [0 0 1] is a z vector in 3 dimensions (without the homogeneous coordinate), is just silly.
Why did we do this to ourselves?
I think going forward next gen 3D engines will have to account for the improvements in GPU hardware realized by advances in machine learning. Mixed precision matrix multiply at massively parallel scale. As well as the demands of next-gen games. Things like real time ray tracing of deformable meshes ;)
So, the actual point is that the word quaternions (and "these strange i, j, k") is confusing. Rightfully (at least for anyone without a background in maths or physics).
"Let's remove Quaternions from every 3D Engine" -> "Let's remove the word 'quaternion' from every 3D Engine"
(Nice explanations and visualization, anyway!)
No need to distinguish here between API/CLI/GUI.
Check out the demo https://observablehq.com/@enkimute/animated-orbits
Join the discord https://discord.gg/vGY6pPk
Quaternions are actually a separate 'thing' when compared to vectors (which is why their multiplication seems off and the square is a negative number).
Quaternions should be considered a versor (a rotation around great circles), that is a change in direction which is different from a vector.
See this work: https://archive.org/details/cu31924001506769/
We do 4D stuff in 3D engines because it leads to massively nicer and simpler math, like replacing extremely large trigonometric calculations with a few additions and multiplications. It is actually the right way to do things. And bonus fact: it actually makes logical/intuitive sense when you actually try to understand the math.
After that, you can’t argue that geometric algebra is not THE right way to do geometry.
Projective geometry (in any dimension) is a subset of geometric algebra.
Please watch it.
To be able to unify many geometric objects, like lines and spheres and point pairs and represent the duality e.g. the "meet" of two lines constructs a point (possibly a point at infinity) and the "join" of two points constructs a line (not sure what happens if the two points are identical), .... then you need 5D which is really like 2^5 = 32D in my mind.
But if all you're trying to do is stop being confused by two different things that both look like vectors, but transform differently under spatial transformations (i.e. any vector that is the result of the cross-product is really a different type of vector than the argument vectors, or e.g. normal vectors) then 3D GA is fine. Though really it's more like 2^3 = 8D (1 scalar, 3 regular basis vectors, 3 "axial" basis vectors, and one pseudo scalar).
An efficient implementation would likely need to use a type system avoid representing 8 dimensions directly. Like the cross product of two vectors will produce an element where only the "axial" components are non-zero.
> 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.
I tend to agree with the author. I find it a lot harder to work with concepts I don't understand: I'm forced to "fly blind" and just plug in formulas and hope everything works. At the latest when you have to debug something, this can go horribly wrong and leave you without a lot of options.
Besides, your GPU shader code implements fast quaternions, and you aren't going to get NVidia to replace them with rotors. So the game is lost.
Oh, unless you don't mean "understand everything" and are going to draw your arbitrary line at the GPU.
Different people will be okay with different levels of understanding. You put "deep" in quotes. You should also put "heuristic" and "easier", and many more, because all of these terms are up for analysis now.
A very heuristic operation of technology is "power cycling"--"have you tried turning it off and on". Another version is "factory resetting". This is very useful, but without a slightly deeper understanding of what is does, or how computers work, it's easy to waste time doing it. Like if I get a cloudflare message saying some website is unavailable, I'm not going to log out and back in. I'm not going to turn my computer off. I'm not going to do anything. But that requires a slightly deep understanding.
I wouldn't try to argue what's easier and what's harder for people so generally. There are lots of different kinds of people. That's why both the quote and the grandparent are explaining their personal motivations and describing themselves. I mean, you kind of acknowledge this after the fact when you talk about "arbitrary lines", but it still sounds like you're dissing someone's "arbitrary" personality. I mean, yeah, even if it were arbitrary drawn at GPU---that's the sense in which we are individual people...
From my personal experience, it can pay off immensely to understand the internal structure of the representation you're working with. I can look at a 4x4 matrix and immediately identify some stuff (does it include a translation component? does it scale and is this scale uniform? is it rotated and around which axis?).
Meanwhile, I can't do this with a quaternion. I know what they do and can understand how, but I have no intuition for what the four numbers mean.
Game development is not fundamentally more hard than any other field of applied engineering or mathematics. It isn't theoretical mathematics. You just use the math.
Needing to "understand" root construction before "being able to use" is just procrastination.
Star citizen needed 64 bit positioning for real world planet scales in game, that had to be hacked into cryengine...
since I feel personally attacked by that statement (I say in jest), it's more charitably viewed as a risky investment. Understanding now might help you use it more efficiently later.
3D Rotations are traditionally very tricky to represent in a computer! It's only in "modern" times that basically everyone has settled down on quaternions as the best parameterization. I think the comparison to anything about real numbers misses the point. It's not about rotors themselves, or real numbers themselves, it's about how they model something we care about. Money isn't a real number, but we model a balance in an account using one. And an accountant definitely needs to understand operations such as "debiting", "crediting", "accruing interest". So they need to understand addition, negative numbers, and multiplication. But that's just because of the choice of the model.
funny enough, it seems like lots of accounting existed a while before negative numbers were obvious, so there are all sorts of to-me funny ways of representing negative numbers, or subtraction (I don't have any clear evidence to back this up). Everyone was doing accounting just fine before, but really it just feels more obviously elegant to use a negative number to represent a deficit.
Also :
You "can" be a "good" engineer while thinking the Earth is flat. (Unless you're working on space-related projects of course.)
You "can" be a "good" scientist without knowing anything about epistemology, Popper, Kuhn...
(But can you, really, be a good one ?)
(Also IMHO most of today's economists are just charlatans akin to the astrologers of old, misusing math because math gets your more respect, and it's probably related...)
(by moving the world around the origin)
I doubt using the concept of rotors in place of quaternions would've made my experience any better. It's not the concepts that really frighten me - I can read about them and nod my head, pretending that the information is somehow sinking into my brain; the things that scared me were the equations which, the article implies, are pretty much the same.
In the end, the things (seem to) work as intended in my library, and I can now sleep at night knowing I'll never have to revisit quaternions (or rotors) again in my life.
[1]: https://www.youtube.com/playlist?list=PLpzmRsG7u_gqaTo_vEseQ...
I don’t claim to have delved very deep in the topic before, but of course it is standard to start with definitions - and I found these definitions particularly clear & disambiguated.
That said, tensors are in fact more general than geometric algebra’s multivectors (in that the latter form a quotient algebra of the former). But not all tensors correspond to manifolds as we know them in physics and I argue that GA keeps track of the geometric properties we want better.
Historically it seems like 3D geometry and particularly cross products in the context of electromagnetism fomented the primary demand in mathematics education for students to be taught vectors. Unfortunately the mathematics curriculum (in Western countries) has not really been updated in decades to better prepare students for the jobs of today; we still enroll all students in a sequence that culminates in differential equations and particularly in second-order linear differential equations, which just so happen to be crucial to control problems in electrical and mechanical engineering. While many people's jobs involve some kind of mathematics somehow, only a few jobs involve the mathematics of electrical engineering, and I suspect that is part of the reason why so many students are bored in math class.
And even further :
IIRC, you don't need cross-product for electrical engineering, and IIRC it (thankfully) isn't (generally?) taught in high school.
Furthermore, later, in college, it would seem that electromagnetics get easier when taught through bivectors rather than cross products (and you avoid the traps with pseudo-vectors and, later, gimbal lock with Euler angles ?).
Maxwell's multiple equations seem to condensate to a single one under GA !
(What if we teach GA it will open the possibility of teaching EM in high school ?)
The biggest disadvantage of using quaternions over Euler axis/angle representations is that quaternions are basically impossible for humans to visualize, whereas Euler axis/angle representations are easier than transformation matrices, Euler angles, or any other representation.
So why not just use Euler axis/angle representations instead? Nobody cares any more about evaluating cosines at 1 kilohertz, and there would be none of this complicated geometric algebra stuff that nobody understands.
Composition of two rotations in axis/angle representation basically proceeds via the quaternionic formula, ie in terms of half-angles. So if you need to do that a lot, it makes sense to go fully quaternionic to avoid having to work with both full and half angles.
He's given a lot of talks on subjects like this. I imagine that what he's doing mathematically is a lot more intricate than most games need though.
He posted an update on the game recently: https://marctenbosch.com/news/2020/01/miegakure-update-end-o...
On the other hand, almost nobody mentions the nice geometric perspective that unit quaternions offer that are somehow "lost in translation" in GA: as a compact Lie group, unit quaternions come endowed with a bi-invariant Riemannian metric which means you can do interpolation, clustering, blending, statistics with them in a metric-consistent manner. And since the metric is compatible with the group structure, the geodesics are cheap to compute.
If the idea is use a higher, more pure math structure, then one can go to even more abstract math formalisms, such as coord-free calculus and bigger algebras, but these, like GA, add more computational overhead to solve problems that don't exist.
Hestenes et. al., the main popularizes of GA in the math/programming intersection, have papers on writing raytracers in both, and they too clearly demonstrate loss of performance using GA.
Now we have twenty, twenty-five years of code and resources that make use of quaternions. In some ways, game development is incredibly hide-bound and conservative, and for the most part eschews rigid correctness for performance, convenience, and a loosey-goosey good 'nuff feel.
And this only happens because the planes are defined as "xy", "xz" and "yz", rather than the more consistent "xy", "yz" and "zx"?
If you just changed the definition of the planes at the start of the derivation, it seems you would end up deriving the exact same operations as you would use with quaternions? I'm not sure if there is a good argument for not doing that.
I'd also be really interested to see some more applications. I wonder what rotor interpolation looks like for example? I know I've had problems with quaternion interpolation in the past.
What is odd about the quaternions' multiplication tables? Is it the fact that the commutative property of multiplication is violated? For the sake of argument, let me assert that it is.
What if at the highest level of abstraction x * y had no obligation to equal y * x?
I'm not sure, but the article's implication that nobody else cares why things work to be distracting and insulting.
> Personally, I have always found it important to actually understand the things I am using.
https://www.youtube.com/watch?v=PNlgMPzj-7Q&list=PLpzmRsG7u_...
This also shows that the talk of needing to visualize 4d to understand quaternions is disingenuous. The formula for using a quaternion to rotate a vector is qvq^-1, from which it is immediate that changing the length of a quaternion does not change the rotation it represents. So you can just deal with unit-length quaternions, which form a 3D space.
Much the same with argument here, sure GA would be better, and maybe that may well come about, but alas quaternions are somewhat known by the many over the few and a bit of a QWERTY situation plays out.
I work in a research field that uses rotations heavily, and trying to use things like Euler angles (with 4 or 5 competing representations) and axis angles has created nothing but confusion among people. If people used quaternions from day one, it probably would have saved, cumulatively, the time of several dozen phds.
Likewise, IMO, learning to use Rotors is easy, but learning how they work is much harder... It's just that it's easier than learning how Quaternions work.
And, also IMO, you don't need to know how either of them work to use them in gamedev. It's fine to use a library that understands them and just continue making the important parts of your game.
Oh that's indeed absolutely what a game dev should do.
A 3D engine dev however, might do well to eat the math leading to the understanding of quaternions, and by extension Clifford algebras (the underlying/original theoretical structure leading to geometric algebra). You get to understand how particular variations in n-dimensions of this structural framework are isomorphic to all numbers like R, C, H and much more. (hyperbolic! dual!)
It really paints a whole arch-picture, a meta-framework to unify all possibly kinds of numbers in one's mind (including the geometry of these numbers and ring operations, with a 1:1 equivalence between geom and algebra).
Note that this is why, I think, some strong proponents of GA (which I find myself agreeing with in that regard) would have it enshrined in K-12 education in lieu of linear algebra — because the intuition of GA is really great / second-to-none, and intuition is all that most math students in high school will ever retain afterwards (they won't do math again, ever, not really). The argument being that people who need more (from linear algebra for calculations notably) can learn that complicated and non-intuitive stuff later (university), building on top of a good base intuition nurtured in GA / Clifford.
So, the 3D engine maker, people in robotics, anyone working with spatial representations of any kind (even abstract, like research with multilinear models) would do themselves a fantastic favor for a lifetime to learn these topics. It's a no-brainer, really, from the other side.
It's delicious math!
* GA provides some nice savings when it comes to rotor/3D calculations, provided that the underlying data structures and architecture supports them. Check out the publications by Dietmar Hildenbrand and his team for several examples:
- https://www.researchgate.net/profile/Dietmar_Hildenbrand
* Quaternions start to exhibit several limitations when dealing with complex objects, even in 3D. It provides just the necessary structure to store quadrature information to avoid the "gimball lock" issue, for example. However the fact that it collapses the scalar with the pseudoscalar presents several problems again in calculations with dual quaternions and higher dimensions (projections, for once), and it's not much different from the hurdle of having to discriminate axial and polar vectors in Vector Calculus. The main issue is that its handedness doesn't scale well and has problems capturing the geometric nature and physics of the world in several dimensions (ie symplectic geometry).
* IMHO the real usefulness of GA is that, as it name implies, it's an algebra. That is what Clifford, Ball, Lie and Klein realized while extending the work of Grassmann on exterior algebras, screw theory, vector spaces and differential forms. Matrices, quaternions and some forms have awkward behaviors when they are treated symbolically as algebraic objects, being "leaky" on information or having singularities just because they are not the best representation. GA fixes that allowing you to formulate problems symbolically, and then you can almost blindly solve the equations with high confidence that the result will be sound. You can then convert the objects back to your favorite representation. For good examples, check out Terje Vold papers on:
- Rigid body dynamics: https://www.researchgate.net/publication/241273951_An_Introd..., and
- Electrodynamics: https://www.researchgate.net/publication/245345681_An_introd...)
[Note: Watch out for some typos]. For comparison, take a look at Featherstone's 6D Spatial Vector representation, which is similar to screws and I think shows the best you could do with Vector Calculus objects:
- http://bleyer.org/files/A%20Beginner's%20Guide%20to%206-D%20....
https://grassmann.crucialflow.com
The Grassmann.jl package provides tools for doing computations based on multi-linear algebra, differential geometry, and spin groups using the extended tensor algebra known as Leibniz-Grassmann-Clifford-Hestenes geometric algebra. Combinatorial products included are ∧, ∨, ⋅, *, ⋆, ', ~, d, ∂ (which are the exterior, regressive, inner, and geometric products; along with the Hodge star, adjoint, reversal, differential and boundary operators). The kernelized operations are built up from composite sparse tensor products and Hodge duality, with high dimensional support for up to 62 indices using staged caching and precompilation. Code generation enables concise yet highly extensible definitions. The DirectSum.jl multivector parametric type polymorphism is based on tangent bundle vector spaces and conformal projective geometry to make the dispatch highly extensible for many applications. Additionally, the universal interoperability between different sub-algebras is enabled by AbstractTensors.jl, on which the type system is built.
Join = ∧, Meet = ∨. Vector = point, Bivector = line, Trivector = area, etc. The figure spanned by points (a,b,c) = a ∧ b ∧ c. The boundary of the figure = ∧^(k-1) of the metric (a,b,c), equal to ∂(a,b,c) = a ∧ b + b ∧ c + c ∧ a.
I have a very amateur blog that I never publicize about this stuff and I had a long post about this, but I've taken it down for now to rework it, or I'd link it here. Suffice to say there's a lot of connections and I feel like there are even more here that haven't been discovered yet.
The book "Oriented Projective Geometry" by Stolfi has a lot of this, although it doesn't explicitly talk about geometric algebra or the wedge product -- but it uses all the same symbols. I'm on the lookout for a better reference that bridges the gap.
[I have so far not figured out what the exterior derivative means in projective geometry, besides being dual to ∂; I believe that if derivative operators are just dual to basis vectors, then d is literally just dual to ∂. Not sure. I also have no idea what the geometric product means, and tend to be skeptical of it for that meaning.]
Rotations in 3D are a whole different beast...
That really matters for defining smooth paths, quaternions simply have the right topology and rotations don't.
In particular, he’s explaining that quaternions are not vectors, they’re actually oriented planes and showing how their multiplication rules arise in a way that’s not ‘out of thin air’.