Hacker News new | past | comments | ask | show | jobs | submit login
Let's remove quaternions from every 3D engine (2018) (marctenbosch.com)
627 points by lelf 18 days ago | hide | past | web | favorite | 326 comments

> As a side note, Geometric Algebra contains more than just Rotors, and is a very useful tool to have in one's toolbox.

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.

I'm a former game engine lead from many years ago, from around the time that quaternions were becoming popular, since we never used them before the early 2000's, really, as 3D was young and rotation matrices sufficed.

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.

Quaternions are also quite a bit more efficient (both in flops especially when composing rotations frequently) as well as storage space (4 values in a quaternion vs. 9 in a 3D rotation matrix).

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.

Could you elaborate more on interpolation and weirdness of composing quaternions? I thought a big selling point for quaternions was the ease and naturalness of just using slerp, whereas with euler angles a similar approach gives bad results. When you mention rotations about a vector, do you mean you decompose the desired rotation matrix into axis/angle? Otherwise I'm very impressed by your ability to visualize compositions of arbitrary rotations.

You can't solve the problem of avoiding gimbal lock in arbitrary rotations, so you rig the game not to ever have arbitrary rotations. You cheat, basically. Gimbal lock is a huge problem in software where free form rotations are allowed, such as 3D modeling packages, CAD, but in games, since we control the world, we can set it up not to have these problems.

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.

There are a number of problems with your assessment in modern day engine design I think.

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.

Quaternions (a.k.a. rotors) are by far the easiest representation to interpolate and compose.

Matrices and Euler angles are both horrific to interpolate.

Gimbal lock is a problem for euler angle representation of rotations, not rotation matrices themselves. You can fix it for euler angles the same way they used to for old mechanical gimbal gyroscopes. By having a fourth rotation of the frame that points the singularity out of the way. This is a typical solution in navigation for dealing with the poles of the earth (a wander angle frame).

Wikipedia says that then the fourth one needs "to be driven" to stay perpendicular with the 1rst one (otherwise a "double-gimbal lock" would still be possible, I guess ?). And this "active driving" is likely to complicate the design even more ?

For sure for a real gimbal, I'm just saying that you can do the same thing mathematically to avoid singularities when dealing with rotations represented as euler angles.

Grass Valley Group used quaternions in their Kaleidoscope real-time digital effects system which was launched in late 1987. It was a fabulous machine.

As an engineering manager who's had to push adoption of new technologies, I feel this argument in my bones.

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.

> 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?

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 haven't worked on large gaming projects, but I've worked on large CG feature films. I was a little horrified about how aggressively they adopted some technologies. The theory was that Pixar proved a lot of their technologies in their short films (Disney a bit of that, too, in previous years). The studio I was at didn't do that and both Disney and Pixar seem to have moved away from that at least a decade ago. Very very rarely, they'd repurpose old projects or chose a sequence or specific department for releasing something--that often was a mess (resources spent at the "boundaries" instead of shoring up the new tech).

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.

I would hope any good principal engineer spends a decent amount of time considering switching costs and impacts of new technology. Sounds like this isn't your experience though?

These problems are not inherent of GA, but of (flawed) implementation details and deeper social problems. GA code boils down to essentially the same computations as 'raw' Linear Algebra, and should be implemented as such. Your math centered programmers fell in love with the idea without ever figuring out how to really use it.

I completely agree it wasn’t inherent to GA, but I wouldn’t summarize it as they didn’t figure out how to use it. They were fluent, the problem is the rest of us weren’t.

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.

I'm not sure you are fully understanding the situation. What jessermeyer is saying is that 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.

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.

> I'm dubious about your assessment of your coworkers fluency in GA.

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.

For the record, I'm not saying everyone should not implement GA this way. The major proponents of GA are typically academic, who are interested in its abstract properties of computation. In this setting, it's probably a reasonable approach. But this is a completely different problem than engineering a game-engine which strongly encodes constraints into its solution. It's more like plumbing than math.

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.

It sounds like one shouldn't have expected much of these coworkers, or rather should have expected their error, given that the academics studying GA haven't found efficient compile-time translations for GA into a performant solution with matricies?

Yeah, beating implementations of matrices is a tall order at this point in history...

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.

Without knowing more context it's a bit hard to respond, but from what you said, it sounds like they wrote an abstraction layer above matrices that observed GA semantics, which required a lot of run-time conversion. This is a flawed implementation, especially for a game engine. It's like writing a v-table for matrices to support every general case when you only need 3 or 4 specific instances anywhere in your code.

Time spent -- You're probably right. For new technology, it's probably worth the research to see if code clarity is worthwhile...

Not necessarily on top of matrices... I can easily imagine a part of an engine working with GA and then having to translate back or forth to matrices whenever it needs to interact with another (outside) part of the system.

Translations like this are probably not a great idea in a game engine but I'm willing to be shown an example where it's the Thing You Want To Do.

Oh, yeah, it's a terrible thing to do, absolutely. All I'm saying is that you can have a perfectly consistent /component/ using GA, but if it's living in a larger ecosystem of matrix-based code, you're going to have to do these translations somewhere. (eg, we rewrote the camera compoent in GA, but the dudes doing grass modeling haven't converted.) You get an all-or-nothing problem: it's efficient if the whole codebase is using the same abstraction, but converting around between a bunch of abstractions will come with a cost.

Yeah, I don't work on codebases of that scale so I can't really comment knowingly of what cost it would take to move the whole parcel over the GA. Probably highly dependant on code / social org.

Right, as a physicist, this may be super naive but matrices are just representations of the underlying algebraic structure so I'm not sure why it isn't possible to merely do both once you've decided on a way to convert between the two.

Rotors in geometric algebra form a “double cover” of rotations, for example using unit quaternions there are two different quaternions (q and -q) which will map to the same rotation matrix. This means that mapping from rotation matrices to quaternions is a bit fraught - you need to pick a “side”, and if that side happens to be opposite to what another part of the code (perhaps the part only using quaternions) chose, you’ll get some whacky stuff happening. The same idea applies for geometric algebra.

I feel like this requires the same concern when replacing any system. Even if the new tool is better in theory, does it have enough people using it/experts working on it that it is better in practice and does the costs of replacing it justify the improvement.

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.

The wikipedia page for GA, and in particular the introduction, is an absolutely perfect example of the horrible quality of math pages on wikipedia.

Thanks for saying this. On other math topics on wikipedia, I've read, re-read, and re-read them and still felt like I didn't understand. Maybe it wasn't all my fault.

I think the Wikipedia math articles are not horrible, if you already know the concepts involved and just need a bit of a reminder on something. If you don't know them, though, they're not a good way to learn, IMHO.

I've multiple times heard mathematicians says Wikipedia math pages are bad, and even experts in an area can be confused by the pissing of other experts in that same area.

Math on Wikipedia is just absolutely atrocious.

Remember, wikipedia is an encyclopedia, not a textbook

This is more or less the thing with "Category Theory".

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.

You mean there's a way to establish yourself as an arcane code wizard and make yourself irreplaceable? Sign me up!

It's more like:

"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.

Except what you said is not true at all.

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.

Nice preconceptions, they truly add to your argument.

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.

> CT brings nothing new to the table in terms of "now we can do X that we couldn't do otherwise".

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.

That just means the concept is ahead of its time. People scoff at things they don't understand before that thing takes over the world.

But they also scoff at things that never take over the world. So it doesn't actually mean that it's ahead of its time. It could be an overcomplicated mess that you don't actually need, and it could to be that forever.

Except that post says he doesn't understand it.

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.

I'm not sure where you're getting this. 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.) He said that if you use category theory on a project, now nobody on your team understands the code. But that "you" probably doesn't mean "if you are on my team and do that, I won't understand it". It probably means more like "if one uses category theory", that is, if you use it on your team, this is the result, if I use it on my team, the same result happens.

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.

My email recorded a more hostile version of your original comment before you edited it. I will post it here:

>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.

Yes, that comment was too hostile, and I apologize. It was not up very long; I thought better of it almost immediately.

> ... 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.

Imagine you're in a public place and some stranger is following you around and replying to your comments constantly day in and day out. It's annoying and creepy af.

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 deliberately following you on HN. I find you mostly on threads about computer languages; I visit a number of other topics, whenever I find them interesting.

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.

I'll tentatively believe you for now that you aren't stalking me. But you are borderline creeping me the hell out.

>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.

>If you reply to any one of my other posts I definitely will request his aid to moderate. BACK OFF.


His initial post said the "team" doesn't understand it so I took it to encompass "him" as part of the team. My post is in response to that.

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.

GPUs don't have dedicated matrix hardware anymore, making it questionable whether you really need to convert your GA structures to matrices first. [1] finds that quaternions are faster than matrices on modern hardware; I find that questionable, but it at least shows that they are comparable.

1: https://tech.metail.com/performance-quaternions-gpu/

The APIs (D3D, etc.) do use matrices, and that's all that matters from the point of view of an engine developer. Composing quats together is certainly faster than composing matrices, but quats are limited (no translation / skew / perspectivce / etc.), so there is no direct apples-to-apples comparison between quats and mats.

> The APIs (D3D, etc.) do use matrices

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.

They let you upload matrix data to the gpu, but all functions like glUniformMatrix4fv() really do is upload a 16-vector into gpu memory (and optionally reshuffle its layout). The shading languages also have matrix primitives, that's just sugar.

Thank you for the anecdote! Sorry to leave such a small comment but I believe you meant “foisted it on everyone”, not “hoisted”.

Foisted is indeed a better choice there, whatever I thought I meant. Thanks! I thought about editing, but I’ll leave it so as not to disturb your comment.

I'm sure everyone's been in a situation where so much sh*t was dropped on them that a hoist must have been involved ;-)

Although the fact that GPUs are not ready for GA .. forcing a model that cannot fit onto hardware is quite a massive naive mistake.

That's not about "not being ready", the GPU really doesn't care whether the numbers it is multiplying are coefficients of a matrix or a bivector.

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.

Who has time for that? Me. And, presumably, Marc ten Bosch. When you want to make a game that uses full 4D graphics, existing libraries just don't cut it, and writing GPU code to understand arbitrary-dimensional rotors is worth it.

The main issue here is that they tried to port what sounds like a mature code base. Imagine changing programming languages! They should have restarted from scratch, and with a team fluent in Geometric Algebra...

IIRC matrices are still required in Geometric Algebra ? Maybe by "matrix math" you mean "Vector Algebra? "

I'm not the grandparent. I'm not sure what you mean by "required", but, no, I don't think so.

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".

OK, after refreshing my memory on GA, it seems that one of the nice things about it is that you don't have to think about the "row" vs "column" vectors present in "Vector Algebra". Which are usually represented in the form of matrices. But you don't "need" them in GA, since you can directly work with vectors (= arrays) ! (Which makes it even more curious as to why matrices would be more efficient for 3D work ??)

I think I understand roughly what you mean when you distinguish row and column vectors. For example, let [x, y] represent a row vector and [x, y]^T represent a column vector. If you have a function f that maps [x, y]^T -> z, (you might write it z=f(x,y)), then the gradient(f) is a function [x, y]^T -> [x, y]. That is to say, the gradient is a row vector. It's a different kind of vector than the input to f. And it transforms different (c.f. https://math.stackexchange.com/a/3200912/)

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.

lol, ok - so then it's more the opposite - in GA there are row an column "vectors" (3-components)... but they are not "enough" (for that R^8 representation), so a matrix representation might be misleading ?

From reading a lot of comments it seems like misinformation. One thing worth keeping in mind is that game developers are highly risk averse. For good reason.

Isn't the data structure that supports quaternions just one dimension up from matrices? Why not continue using matrices and retain that last dimension seperately somehow? Then it doesn't require having to retool the GPU/matrix side of it. IE you will have multiple matrices where you would have had one otherwise.

> Fixing gimbal lock with quaternions

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.

I'm a pure math dude at heart, even if I don't get to do it much any more.

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.

Friesland (formerly part of Melitta) sells the kettle for about 37 euro. If you have a way to add the messaging, you are well on your way.


Hahaha! That reminds me of the time I couldn't recall the name for "leaf blower" and called them an "air rake".

If anyone's curious the story is here: https://en.wikipedia.org/wiki/Utah_teapot

> I would like to own an OpenGL kettle

Do you mean the Utah Teapot?

Yes -- I don't even know why I had the word kettle in my head.

I knew what you meant and didn't even consider that it was the wrong name, for what it's worth.

Kettle and teapot are synonyms as far as I'm concerned.

These are different equipment.

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.

Earlier-time kettles may be more common than you think.

Either way, a water kettle is super useful, often surprisingly so.

Definitely a kitchen gadget I'd recommend to anyone.

Kettles go on the stove (or have a built in heater), and are used for boiling water.

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.

When I visited Dublin that was the one spot I absolutely had to visit. For some folks it was the Temple Bar, for others the James Joyce trail. For me, it was the plaque on the Broombridge and the Trinity College Library.

If you ever happen to be near a Siggraph the render man guys hand out little walking Utah teapots - a tradition going back many years apparently. Worth the price of admission :-)

I explicitly made a detour when I was in Dublin to take a picture of it the plaque on that bridge. Worth it.

Any idea why the name Hamilton appears to be deliberately defaced on the inscription?

> I answered, "i^2 = j^2 = k^2 = ijk = -1".

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)

> the multiplication rules followed from the desire to define the square root of a negative number

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.

>Quaternions are an attempt to do that in 3D.

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?

It can be generalized, but doing so requires some subtlety. The naive approach (the Cayley-Dickson construction) can be repeated ad infinitum, but it doesn't continue to yield useful results for representing geometric interactions like rotations in high dimensions.

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.

You can't get the associative property in higher dimensions. There is something called octonions (which is not associative but has some similar tho weaker properties) https://en.wikipedia.org/wiki/Octonion There is a sequence of such structures, but after the Octonions you get non-zero numbers that multiply to zero: https://en.wikipedia.org/wiki/Cayley%E2%80%93Dickson_constru...

> I guess the question is, why does it then stop. Why not a 4D alternative.

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)!

> geometric algebra just has division

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?

Here's a Math StackExchange thread that gives the procedure I'm familiar with: https://math.stackexchange.com/questions/443555/calculating-...

I still haven't wrapped my head around quaternions, but 3Blue1Brown on Youtube has a good series of videos justifying and explaining the complex numbers and quaternions in terms not of sqrt(-1) but of transformations of space.

I think the answer to that question is that it doesn't "stop", but I'll try to offer a reason that isn't "octonions exist", but instead goes in a different direction.

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...

By the Frobenius theorem, there are only three possible structures for a real finite-dimensional associative division algebra. Those structures correspond to the real numbers, the complex numbers, and what are called the quaternions. So essentially the above definition is not arbitrary because it's the only other possible way (besides R and C) to get that sort of algebraic system. Of course, this is not obvious at all. C famously is algebraically closed as a field, which makes it a ripe playground for much of topology, algebraic geometry, and analysis. There are some nonobvious generalizations of algebraic closure for the quaternions. (Naively, the quaternions are not algebraically closed in the classic sense because, evidently, ix + xi - j has no root.)

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.

When I took abstract algebra as an undergrad, we did a brief bit on the quaternions. Bursting with curiosity I asked the professor if 8 and 16 dimensional structures existed. "Of course! But just as you lose commutivity with Q, when you go to the octonions, you lose associativity, and the sedonions lack "alternativity" (had to look that up -- I didn't remember) and they're basically algebraic novelties with out any application."

Right, but while the Cayley-Dickson construction mostly provides novelties (though I remember reading something about octonions and string theory[1]), Clifford algebras are derived differently; they are isomorphic to complex numbers and quaternions for two and three base vectors respectively, but they produce something else after quaternion. This "something different" can be used to represent, you guessed it, reflections and rotations in a 4D space. Because they are not obtained from the Cayley-Dickson construction they are not division algebras, however.

[1] https://www.quantamagazine.org/the-octonion-math-that-could-...

That amazing graphic !

As other replies have said, the math is kind of important. The idea of a tattoo harkens to the story of the discovery of quaternions: Rowan Hamilton was out for a walk in Dublin, trying to figure out how to generalize complex numbers. He was walking under a bridge when he came up with that equation, and carved the equation on the bridge.

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.

My PhD advisor was a stickler for citing original sources. Really, really original sources. He made me cite some papers written by Lagrange in the 17th century in French, when neither he nor I nor nearly anyone else who would ever read my dissertation could speak French.

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.

For a summary of William Rowan Hamilton's life (including the bridge story), see this amazingly clever video based on the song from Hamilton: https://www.youtube.com/watch?v=SZXHoWwBcDc

There's also a great book "A History of Vector Analysis: The Evolution of the Idea of a Vectorial System" by Crowe which covers vectors from Complex numbers to Gibbs vectors and includes Hamilton and the competitor at the time Grassman Algebra, both the basis for geometric algebra.

Its one of the only maths history books I couldn't put down.

Thanks for writing this. It was indeed a large part of why I like it. I added more detail in a reply to the parent post.


I'm not a mathematician, but I think it's about extending the idea of a scalar and a single rotation (Complex numbers) into a scalar + 3 rotations (Quaternions). The idea can be extended further to a scalar with 7 rotations - https://en.wikipedia.org/wiki/Octonion, but no further, for reasons I don't understand.

You can actually go as far as you want to with the Cayley–Dickson construction [1] of algebras.

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...

[2] https://en.wikipedia.org/wiki/Sedenion

[3] https://en.wikipedia.org/wiki/Alternative_algebra

Thanks for writing this! I referenced it in a reply upthread for why I like the equation.


You lose the ability to divide after the octonions.

I got busy, so I wanna say thanks to everyone who tagged in for me. So many great answers. I'll link a few that speak the most to my own feelings.

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

It's nice to see something other than e^(ᴨi)=-1.

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.

[1] https://en.wikipedia.org/wiki/Riemann_hypothesis

[2] https://arxiv.org/abs/math/0008177

I'm curious about that "almost all" ?

All but a set with measure zero, in this case.

Why just not say "non-zero" then ?

"non-zero" is not the same as a "all but a set of measure zero". Here's what "measure zero" means:

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.

Then you could dress up for Halloween as Broome Bridge!

I love quaternions, but I have to ask: you'd rather have that formula than Euler's identity tattooed?

Today, mathematicians in the most general sense divide into algebraists and analysts. Tattooing Euler’s identity identifies you as a member of the analyst tribe, you live and breathe limits, sequences, and measures. A tattoo of Hamilton’s i^2 = j^2 = k^2 = ijk = -1 would identify you as a member of the algebraist tribe, who lives and breathes commutators, cohomologies, and quotients.

Thanks for writing this! It's spot on. I referenced it in a post upthread[1].

[1] https://news.ycombinator.com/item?id=22204995

As another algebraist (category theory and computational complexity), this makes a lot of sense. Euler's identity is capricious and Euclidean to me, and far from the most beautiful equation, although it is still remarkably elegant. I don't have any tattoos, but I might consider some categorical diagram; I don't know how I'd pick just one! Perhaps there is some cool way to draw the Snake Lemma with a realistic-looking snake.

> I don't know how I'd pick just one!

picking one up to unique isomorphism should be good enough ;)

Mine would be the Fano plane mnemonic for octonion multiplication, using two curves of constant width instead of the triangle and the circle. That's got the quaternions covered with the inside curve.

It can go next to the skeletal formula for benzaldehyde on my imaginary nerd canvas.

Brilliant !

I’d probably go with “e^pi*i = -1”. Kinda cliched, but I really love that equation.

Then you would have worry about the tau-ists: https://tauday.com/tau-manifesto

lol. I'm actually one of them. "e^tau*i=0" is my preferred form. I don't tend to bring it up because we're a little crazy and I don't want to draw attention to myself.

shouldn't it be e^tau*i = 1 if tau is 2pi?

Oops, typo. You're right. You could also write "e^tau*i = 1 + 0" to relate the "5 most important numbers in math" but that form always seemed a bit forced to me.

If you write "-1 * e^(tau * i) + 1 = 0" you can reasonably claim to relate six important numbers: -1, e, tau, i, 1, and 0. IMHO that looks a bit less forced than the version with "1 + 0", though of course it's not the simplest form. (I mean, that "+ 0" could have been inserted almost anywhere...)

Someone once showed me this "big brain" version of the equation: ceil[e] - floor[pi] = 0 :)

What ?

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 ?

Oh yeah, it's definitely just a stupid joke equation. Probably only funny to anybody who's seen Euler's equation a thousand times.

Oh, lol, ok, I didn't get it because I was searching for something less stupid ! XD

Or, better yet, e^pi*i + 1 = 0. (My personal preference is E = mc^2.)

Why not E^2 = m_0^2 c^4 + p^2 c^2?

I'd probably pick the normal-normal conjugate prior, in precision form.

She probably hoped for a different answer.

No, I bet this was exactly the answer they were looking for. After all, it was love at first sight.

I've only skimmed the article, but it seems to be saying this:

> 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?

Your opinionated summary implies that both concepts are equally hard to understand, but the whole point of the author is that rotors are potentially a lot easier to understand and reason about than 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.

> rotors operate fully in 3D, whereas quaternions are in 4D. This means you can visualize rotors ... whereas with quaternions, you have to ... 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.

> rotors operate fully in 3D

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:


Thank you for the link, very cool 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).

No math degree here, but personally I think the author's main point was not purely that they could be visualized without resorting to 4D. Instead I think it was that the concept of rotors can be explained from first principles, whereas he feels that currently, programmers look at quaternions as black boxes for which they have no intuition. Here's the relevant quote from the video:

> 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.

I think different people have different approaches. I can only say that, for me, I usually need some kind of visual understanding of what an object represents - which may be 2D, 3D, a graph structure or whatever else, depending on the task at hand.

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.

> 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.

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?

I don't understand the phrase "rotors operate fully in 3D". What does operating in 3D mean?

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 means the things in the basis, x^y, y^z and x^z have an easy to understand interpretation in ordinary 3D space, namely the parallelogram between x and y (in the case of x^y), for example.

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.

You're probably right, that's probably what was meant. I guess I'm so used to thinking geometrically about quaternions, I don't see much advantage to geometric algebra for 3D rotations (but geometric algebra does have other advantages, like working in any number of dimensions!).

The space of rotors and rotation quaternions are both three dimensional because the coordinates are restricted to unit magnitude.

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.

You're right that the space of rotations is 3-dimensional. When I said 4, I meant without restricting to the unit hypersphere. This causes no problem for rotations because replacing q by a multiple tq leaves the formula x --> qxq^(-1) unchanged --although of course q^(-1) invloves dividing by the square of the norm so it's nice if the norm is 1.

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 are potentially a lot easier to understand and reason about than quaternions

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.

That's not true. Rotations in 3D space are 4D objects: a 3D orientation and a 1D magnitude.

Rotors use a.b with aXb, and quaternions use magnitude and 3D direction vector.

SO(3) is definitely three-dimensional, and rotations don't involve magnitudes.

I miswrote. Rotation calculations are represented (in quaternions and in geometric algebra calculations) as a 3D subspace of R^4, with the "extra" dimension accounted for by constraining quaternions to the unit hypersphere.

Rotations do involve magnitudes when interpreted as an axis (2 dimensional manifold embedded in R^3) and a magnitide (0 to 2pi)


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

Yes, you have that right. The underlying operations are the same. What you are missing is that the ideas from geometric algebra work in any dimension! Quaternions are a “trick” that only works in 3D.

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.

The exterior/wedge product is actually very closely related to the cross product, and works to generalize the cross product to n dimensions. You can read Spivak or Munkres, "Calculus on Manifolds" and "Analysis on Manifolds" respectively.

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 :).

> The exterior/wedge product is actually very closely related to the cross product, and works to generalize the cross product to n dimensions.

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.

This is incorrect, if you read Spivak, you can define and (n-1)-ary product which generalizes the cross product. You give it (n-1) vectors and it gives you a vector orthogonal to all of them.

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).

> This is incorrect, if you read Spivak, you can define and (n-1)-ary product which generalizes the cross product. You give it (n-1) vectors and it gives you a vector orthogonal to all of them.

I never said the wedge was the only way to generalize the cross product, I just said the cross product itself wasn't general.

It's just semantics: what you call the generalized cross product, I call the cross product.

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.

Good points about the cross product, but :

> 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 ?

These words all change meaning over time, mathematical definitions change, old words are used to describe new objects and new words are used to describe old objects. I'm using the word integer with it's archaic meaning here for rhetorical effect, but I'm probably being too obtuse ;)

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.

Oh, missed that part about integers.

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" ?

"five years ago" ?

I have no idea what the kids are reading these days, I've since ceased my aspirations towards pure mathematics.

Maxwell's equations : much more consistent without the god damned pseudo-vectors that are vectors except when they aren't ! http://www.av8n.com/physics/maxwell-ga.htm

But 3D is the D that matters for 3D games. video games are concrete mathematics, not abstract mathematics.

I got me intrigued. Thanks! Could you point to a source that explains geometric algebra from this angle? Book, article, web source, anything?

That's not correct. Mathematically as they describe the same thing they have to be translatable into each other. But one is a natural mathematical definition, the other exploits a completely unintuitive incidental mathematical isomorphism.

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.

On the other hand requires zero memorization.

> ij = k is arbitrary, ...

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.

I disagree, but then I used bivectors extensively in the geometric part of my mathematical research (back when) so I would. ;)

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.... :)

> 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?

> 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 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).

From the complex abacus the romans left us, it would seem that they used both base 10 and base 12 (for fractions - 360° in a circle is an extension of that). Base 12 seems to be slightly better than 10, but switching over would be WAY harder to "finishing" algebra... (and we wouldn't have the quite important these days 10^3~2^10 approximation.)

But they wouldn't extend to 4D.

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.

y^2 = 1 because it is the sum of the dot product (1) and the outer product (0). The latter is because the parallelogram between y and y has zero area. The former is just the length of the vector y.

Some memorisation is required, but it is in terms of things that are easily visualised.

But why would the area be expressed as a length? This always struck me as a coincidence, and having read on bivectors it just makes sense that it would be (because a vector represents a distance on a line, a bivector represents an area on plane, a trivector represents a volume on a 3D space and so on).

Area is not expressed as a length. In general you can't simplify an expression that is a sum of an area and a length (this is one of the features of geometry that GA handles for you algebraically). e.g. "one meter plus one meter" can be simplified to "two meters", but "one square meter plus one meter" cannot be simplified. However if one of the terms is zero you can remove it, so "zero square meters plus one meter" is "one meter".

So x² = xx = x^x + x·x = 0 (area) + 1 (length)

xy = x^y + x·y = x^y (unit area) + 0 (length)

Right, with bivectors as in the article it all works.

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.

Ah, apologies, I see what you're saying now :)

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.

ij=k means that the product of two of the three unit vectors must equal the third, which is a fundamental, non-arbitrary property, and without loss of generality the signs can be chosen so that ij=k (rather than ij=-k). Adding ii=-1,jj=-1,kk=-1 it's easy to deduce ijk=-1, j=ki, and i=jk, and ij=-ji, ik=-ki, jk=-kj.

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"?).

But why would you remember a right hand or left hand rule? bivectors don't require you to.

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.

In my college in Antarctica we were taught

  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.

That's my point, you need to remember "ijk" in order (i.e. i=jk or ij=k) in a purely algebraic definition instead of a meaningless and complicated "handedness" rule involving rotations.

Sure, people who are happy customers of quaternions and don't feel driven to understand what's under the hood, why change?

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.

It's possible to plot the rotation of planets around the earth using very complex systems. Why didn't we stay with that?

Why not change? Comfort?

Why not change? It's a good question. Learning about GA is an investment, getting it coded up and tested is an investment, and the obscurity of GA is going to make the code almost encrypted to people who aren't fairly mathy. Although quaternions are definitely crazier than GA, the sad fact is they're much more popular.

There's some return on all that investment. It might pay off or it might not. I think it's a design decision.

I haven't read that particular article, but from other sources I've read quaternions appear to be mysterious/magical even to people who know them, while the rotors have a very concrete geometrical interpretation in geometric algebra.

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.

The best 3d location/vector method I've used allowed rotations using normal x,y,z coordinates, but you could do rotate an object in the xyz of the engine itself, the object, or the object that object was currently attached to. This made things like shooting a lob from a forward facing gun easy, since you could raise the shot from the gun rather than the world and no quaternions were involved. I don't know if quaternions were used underneath.

I don't understand what you mean, but I think you're describing exponential coordinates, or said another way, choosing an angular velocity and getting a rotation by following that angular velocity for a unit of time. https://en.m.wikipedia.org/wiki/Rotation_formalisms_in_three...

That’s a notational change that incurs unneeded, increased cognitive load. That’s admittedly a mile high view.

Check out my geometric algebra software


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.

Do you have a reference for all the operations you've implemented here? I've found random papers that make reference to ∨, d, and ∂ wrt geometric / exterior algebra, but I haven't really found a comprehensive summary of them, so I've been trying to figure it out myself.

What does the differential operator do and how does it relate to geometric algebra?

There's a lot of connections between projective geometry and geometric algebra (well-- at least exterior algebra. Not sure about 'geometric', because I don't know what the geometric product means). If you implement _oriented_ projective geometry in homogenous coordinates (so a point (x,y) is a vector (x,y,1)), then the meet and join operators are implemented as ∧ and ∨. You can make a little dictionary:

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.]

skratlo 17 days ago [flagged]

Holy cow, dude, I'm going to use this one to make people feel dumb. Craziest cryptononsense I've ever read!

Please don't be a jerk in comments here. It's against the spirit of the site (and also its rules).


Amusingly the discovery of Quaternions by Hamilton was also followed by arguments within the mathematical community as to whether mathematics should be rewritten in the language of quaternions, as Hamilton proposed to do and subsequently spent the rest of his life pursuing. Initially many mathematicians found them confusing, Hamilton's book is unusually difficult to read and there were no others. The work of Grassmann was somewhat neglected at the time, and eventually the Gibbs/Heaviside notion of vectors (essentially what we use today) emerged as a competitor to the quaternions. It seems it was a particularly bitter mathematical divide, up there with Newton vs Leibniz. Here is a quote by Tait, one of the "quaternionists":

"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".

While we're at it, can we please move the homogeneous coordinate to be the first value in memory? That way, a vector or a point, if they're represented sparsely in the data structure, just work.

[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?

It’s puzzling - even in most of the mathematical literature, x_0 is used for the homogeneous coordinate.

Memory layout. You can do a hacky "cast" from a homegeneous 4-vector to a ideal 3-vector for free. Same pointer.

This would mean that you have to make sure elsewhere in your code that the last coordinate is always normalised to 1, so do you win overall using this strategy? Plus, the same cast in the other method is ptr+1, which is assumedly just as fast.

When I was learning graphics, the reasoning around quaternions was to avoid "gimbal lock". It was just taken as orthodoxy without question.

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 ;)

Same critique as I have for the article, though: just because the subject is poorly taught doesn't necessarily mean that the subject needs to be replaced. The key here is that gimbal lock isn't a feature of quaternions, it's a feature of Euler angles: https://math.stackexchange.com/questions/8980/euler-angles-a...

Quaternions can be normalized, thus eliminating numerical errors than can accumulate if you multiply a rotation matrix many times. These numerical errors make the matrix non-unitary, and introduce weird stretches and skews into the transformation.

Quaternions are 3D rotations (plus, possibly, rescaling). The author notes that they have the same API (I like this term used in mathematical context).

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!)

API stands for Application Programming Interface. What is exactly an "API"? Why not just "interface" ? (One should generally avoid acronyms...)

Yes, it should be interface.

No need to distinguish here between API/CLI/GUI.

I agree, it's mostly a matter of words. But just for the record, quaternions in general are 4D isoclinic rotations (with optional scaling). Left-multiplication by a unit quaternion corresponds to a left-isoclinic rotation, and right-multiplication corresponds to a right-isoclinic one. By combining them you can produce any 4D rotation. A subset of this is the set of 3D rotations that rotate ix+jy+kz into ix'+jy'+kz'.

Check out http://bivector.net, a new community on geometric algebra.

Check out the demo https://observablehq.com/@enkimute/animated-orbits

Join the discord https://discord.gg/vGY6pPk

Never heard of this before. Thanks for the share.

The reason many people have trouble understanding quaternions is that they reason about them incorrectly.

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/

I am impressed at the number of people reacting with « Euler angles are fine » or « quaternions are fine, we always did this way ». Having worked extensively with them it is obvious that Euler angles are broken beyound repair (singularities, 12 competing variations...) and quaternion are too (they only work in 3D). This article is extremely interesting and absolutely true. If geometric algebra had been discovered earlier we would never have needed a lot of these unnatural constructs.

Because we're going to start doing computer graphics in 4D?

We already do! You seem to ignore the widespread use of projective geometry in all 3D engines. For me it shows that you don’t know enough about the topic to have a useful opinion on this.

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.

That's hilarious, because I've studied projective geometry for years. I am literally writing a paper based on projective geometry right now (applied to abstract algebra). Projective coordinates still gives you a three-dimensional object, because you identify vectors that are scalar multiples of each other.

Ok look just watch this mind blowing video:


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.

In order to make geometric algebra really nice, you have to go 5D, see versor.mat.ucsb.edu. This imposes a significant computational overhead. Nice things are expensive.

I think that's a different point. To get rotations in 3D you don't need to go to 5D conformal GA.

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.

You are right, 5D conformal GA goes way beyond nice rotations in 3D space, but why stop there? We can have two worlds: computationally expensive, high level, powerful abstractions and computationally efficient, messy abstractions. In some cases of rotation, even quaternions are too much.

You don't need to understand the root construction of Quaternions to use them in game code anymore than you need to understand the root construction of the Reals to be able to do arithmetic in game code. Just treat them as opaque values that have certain operations you can perform to get certain results and be done with it.

The author is arguing against this exact mentality - and I believe, this was one of the main motivations this article was written:

> 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.

So you know exactly how everything in your computer works, because otherwise it'd be too hard to use? I wager the exact opposite is the case: it's much easier to use a computer through heuristics of operation rather than any sense of "deep" understanding.

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.

Shader languages do not include quaternions as primitives, so if you do have quaternions in your GPU shaders, it's your own code (or a library), not NVidia's. What is usually done in shaders is encoding all transformations (rotation, scale, translation) in 4x4 matrices, which are a primitive in all shader languages I know of.

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.

They didn't say "understand everything", but that's the interpretation you're replying to, and it gives me some thoughts.

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...

the math is the same so technically nvidia gpus already implement rotors.

I added quaternions to my Javascript canvas library. They scared the heck out of me - I coded up the functions from scratch in JS, partly to try and 'understand' the concepts behind quaternions, but mainly because I was stupid and over-confident. I am not a math/physics genius!

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.

Not knowing what's behind the hood in floating point numbers and their limited precision leads to all kinds of surprises.


Often. Often missed though.

Almost every component of a game is built on the premise of leaky abstractions that go unnoticed. Texture compression, lighting techniques, physics, audio filters, network latency filters.

There are other uses of 3D than games. 3D Engine != Game engine.

Try building a space game at real-world scale on 32 bit floats. Star Citizen tore apart Cryengine to make it have 64 bit positioning for this very reason.

Kerbal Space Program manages it.

(by moving the world around the origin)

Yeah in singleplayer with lower fidelity that is passable.

> Personally, I have always found it important to actually understand the things I am using. This article is aimed at readers who do find understanding the constructions they use important.

That is the point of my comparison to the Reals. No accountant or mechanical engineer or architect need ever read, let alone understand, any proofs that the Reals exist or the fundamental construction of arithmetic. I know several highly successful economists who don't know the construction of statistics, anymore than knowing that the proofs exist and could be found somewhere, if it ever really mattered (it doesn't). As a developer, you are not a theoretical mathematician. You use math.

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.

> Needing to "understand" root construction before "being able to use" is just procrastination.

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.

Why then engineers do get taught that?

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...)

That's fine if you're building something that's already been made. Games don't do that, when you push the boundaries you need to know how your math works. You won't get more performance than the competition without understanding the tools you are using.

And here we see the other common conceit in the game industry, that graphics make a game.

I didn't say that? There's more ways to push a game than with graphics? That's not the words in my mouth.

Star citizen needed 64 bit positioning for real world planet scales in game, that had to be hacked into cryengine...

It didn't need it. That was just the solution the devs created. They could have done it with 32-bit floats, or hell, 32-bit integers, if they wanted, given the right representation. But they chose 64-bit floats to solve the problem, the problem did not choose 64-bit floats.

It really does need it. 32 bit positioning breaks down fairly quickly on planet scale. Shifting the world origin is not a streamlined process and doing it frequently for each client in a large multiplayer game is nearly prohibitive. You could invest the effort into making world shifting and planet scale work in 32 bit, and the lesser of the two evils would still be implementing 64bit positioning. You gain so much and lose so little for having done it.

That's not how it works in programming in general. Many - if not most - abstractions turn out to be extremely leaky. (For example, you do want to know the difference between the "root construction of Reals" as it is done in mathematics and what is taken to be their representation in the computer.)

Applications are open for YC Summer 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact