
Let's remove quaternions from every 3D engine (2018) - lelf
https://marctenbosch.com/quaternions/
======
dahart
> 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.

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

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

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

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

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

~~~
s_dev
[https://en.wikipedia.org/wiki/Broom_Bridge](https://en.wikipedia.org/wiki/Broom_Bridge)

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.

~~~
andybak
> I would like to own an OpenGL kettle

Do you mean the Utah Teapot?

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

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

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

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

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

Definitely a kitchen gadget I'd recommend to anyone.

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

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

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

~~~
mlatu
> 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:

[https://www.youtube.com/watch?v=d4EgbgTm0Bg](https://www.youtube.com/watch?v=d4EgbgTm0Bg)

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

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

------
DreamScatter
Check out my geometric algebra software

[https://grassmann.crucialflow.com](https://grassmann.crucialflow.com)

The Grassmann.jl package provides tools for doing computations based on multi-
linear algebra, differential geometry, and spin groups using the extended
tensor algebra known as Leibniz-Grassmann-Clifford-Hestenes geometric algebra.
Combinatorial products included are ∧, ∨, ⋅, *, ⋆, ', ~, d, ∂ (which are the
exterior, regressive, inner, and geometric products; along with the Hodge
star, adjoint, reversal, differential and boundary operators). The kernelized
operations are built up from composite sparse tensor products and Hodge
duality, with high dimensional support for up to 62 indices using staged
caching and precompilation. Code generation enables concise yet highly
extensible definitions. The DirectSum.jl multivector parametric type
polymorphism is based on tangent bundle vector spaces and conformal projective
geometry to make the dispatch highly extensible for many applications.
Additionally, the universal interoperability between different sub-algebras is
enabled by AbstractTensors.jl, on which the type system is built.

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

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

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

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

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

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

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

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

~~~
phlakaton
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...](https://math.stackexchange.com/questions/8980/euler-angles-and-
gimbal-lock)

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

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

~~~
paulddraper
Yes, it should be interface.

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

------
Epskampie
Previous discussion:
[https://news.ycombinator.com/item?id=18365433](https://news.ycombinator.com/item?id=18365433)

------
adamnemecek
Check out [http://bivector.net](http://bivector.net), a new community on
geometric algebra.

Check out the demo [https://observablehq.com/@enkimute/animated-
orbits](https://observablehq.com/@enkimute/animated-orbits)

Join the discord [https://discord.gg/vGY6pPk](https://discord.gg/vGY6pPk)

~~~
yantrams
Never heard of this before. Thanks for the share.

------
iorrus
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/](https://archive.org/details/cu31924001506769/)

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

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

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

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

~~~
crubier
Ok look just watch this mind blowing video:

[https://youtu.be/tX4H_ctggYo](https://youtu.be/tX4H_ctggYo)

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.

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

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

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

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

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

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

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

------
DonHopkins
From the title, I was expecting to read an article by a crazy old retro
mathematician shaking his fist and yelling at clouds that we should all go
back to using Euler angles. But this was a much better article than the title
suggested!

------
graphpapa
This seems to be an excellent introduction to geometric algebra, a topic I
have had difficulty picking up so far.

~~~
yiyus
As someone who has to teach GA, may I ask what you tried and what you found
difficult? I see problems with the non-standard notation, for example. I also
think that it is much easier to understand 3D-GA starting with 2D or even 1D,
and of course using a non-formal approach (as we do with vectors). It is also
hard to find nice examples between the very obvious and very difficult stuff.

~~~
graphpapa
I think it is mainly the extra time spent on the foundational definitions -
ie. multiple paragraphs and multiple interactive widgets just to clarify what
is meant by a bi-vector.

I don’t claim to have delved very deep in the topic before, but of course it
is standard to start with definitions - and I found these definitions
particularly clear & disambiguated.

------
epicgiga
Let's remove them from _one_ 3d engine first, and see how it goes.

------
diegoperini
Putting content aside (it's great actually), I love the format used for the
article. Each header is also a link to a time point in the accompanying video.
There are interactive canvases that are also used in the video. The only
missing part is a teacher AI which I can ask questions to (just kidding).

------
Koshkin
They say Geometric Algebra is "the new language of physics" and whatever else;
my problem with this is that, unlike, say the calculus of differential forms
(or tensors), it does not make sense in more general manifolds which are at
the heart of the modern theoretical physics. Geometric Algebra, therefore, is
more like something that, sure, could be taught in high school in an attempt,
for example, to streamline elementary vector algebra and thus eliminate some
nasty questions (should they arise); yet, there is some mental load to it that
may make it not worth the effort...

~~~
moultano
Can you elaborate on that or provide a link? The OP made it seem like it was
strictly more general, and I was getting excited to dive in through that
route.

~~~
Koshkin
Well, nothing wrong with getting excited about and learning this stuff. Point
was, in more complicated cases like (non-flat) [co]tangent bundles GA, as an
intuitive framework, loses any advantage, perceived or real, over differential
forms.

------
scythe
His criticism of the cross product seems more poignant than his criticism of
quaternions in computer programming. One might ask -- why not teach bivectors
in introductory math instead of cross products?

Historically it seems like 3D geometry and particularly cross products in the
context of electromagnetism fomented the primary demand in mathematics
education for students to be taught vectors. Unfortunately the mathematics
curriculum (in Western countries) has not really been updated in decades to
better prepare students for the jobs of today; we still enroll all students in
a sequence that culminates in differential equations and particularly in
second-order linear differential equations, which just so happen to be crucial
to control problems in electrical and mechanical engineering. While many
people's jobs involve some kind of mathematics somehow, only a few jobs
involve the mathematics of electrical engineering, and I suspect that is part
of the reason why so many students are bored in math class.

~~~
BlueTemplar
Puzzles me too.

And even further :

IIRC, you don't _need_ cross-product for electrical engineering, and IIRC it
(thankfully) isn't (generally?) taught in high school.

Furthermore, later, in college, it would seem that electromagnetics get
_easier_ when taught through bivectors rather than cross products (and you
avoid the traps with pseudo-vectors and, later, gimbal lock with Euler angles
?).

Maxwell's multiple equations seem to condensate to a single one under GA !

(What if we teach GA it will open the possibility of teaching EM in high
school ?)

------
GlenTheMachine
A point that I don't think has been mentioned here: quaternions _as a
representation of attitude_ are really just a funky parameterization of an
Euler axis/angle representation. Quaternions happen to be parameterized in a
way that lets you avoid the evaluation of trigonometric functions when
expressing their dynamics. This used to be important, e.g. in aircraft control
systems, because computing power was extremely limited and you didn't want to
have to evaluate sines and cosines in real time.

The biggest disadvantage of using quaternions over Euler axis/angle
representations is that quaternions are basically impossible for humans to
visualize, whereas Euler axis/angle representations are easier than
transformation matrices, Euler angles, or any other representation.

So why not just use Euler axis/angle representations instead? Nobody cares any
more about evaluating cosines at 1 kilohertz, and there would be none of this
complicated geometric algebra stuff that nobody understands.

~~~
cygx
_So why not just use Euler axis /angle representations instead?_

Composition of two rotations in axis/angle representation basically proceeds
via the quaternionic formula, ie in terms of half-angles. So if you need to do
that a lot, it makes sense to go fully quaternionic to avoid having to work
with both full and half angles.

------
overgard
Worth noting that the author is the guy behind this extremely interesting
project to create a 4D puzzle game:
[https://miegakure.com/](https://miegakure.com/)

He's given a lot of talks on subjects like this. I imagine that what he's
doing mathematically is a lot more intricate than most games need though.

~~~
ahaferburg
Oh, thanks for pointing that out!

He posted an update on the game recently:
[https://marctenbosch.com/news/2020/01/miegakure-update-
end-o...](https://marctenbosch.com/news/2020/01/miegakure-update-end-of-2019/)

------
chombier
It is somewhat strange that all these articles/blogs claiming that Geometric
Algebra is inherently superior to Quaternions spend so much time on how
Quaternions are isomorphic to the even-subalgebra of GA3 (hence for all
intents and purposes they're the same) and so little time on the odd-
subalgebra (exterior algebra IIRC), which as far as I can tell is the main
(only?) advantage of GA over Quaternions.

On the other hand, almost nobody mentions the nice geometric perspective that
unit quaternions offer that are somehow "lost in translation" in GA: as a
compact Lie group, unit quaternions come endowed with a bi-invariant
Riemannian metric which means you can do interpolation, clustering, blending,
statistics with them in a metric-consistent manner. And since the metric is
compatible with the group structure, the geodesics are cheap to compute.

------
ChrisLomont
Having written engines using both GA and matrices+quats, as well as writing
articles on GA (one intro one in an old Games Gems book), I'd say GA is a
terrible idea for 3D engines. GA is inherently slower to manipulate, as items
require more storage and more memory touches. They add almost zero benefit.

If the idea is use a higher, more pure math structure, then one can go to even
more abstract math formalisms, such as coord-free calculus and bigger
algebras, but these, like GA, add more computational overhead to solve
problems that don't exist.

Hestenes et. al., the main popularizes of GA in the math/programming
intersection, have papers on writing raytracers in both, and they too clearly
demonstrate loss of performance using GA.

------
o_p
Maybe the blog poster should try to learn how imaginary numbers work instead
of trying to stick with reals, as an EE im probably biased but rotations ->
complex numbers, as they make it much easier to work with it

~~~
BlueTemplar
Rotations in 2D - absolutely !

Rotations in 3D are a whole different beast...

------
radarsat1
Hm. I don't claim to fully understand quaternions, but I simply think of them
as an obfuscated version of axis-angle representation, which seems to serve me
well in reasoning about operations on them.

------
thrower123
Nice thought, perhaps, but I doubt anything would come of it. Quaternions came
into vogue because the problems of Euler angles were very apparent in
practice, but we still think, at best, in yaw/pitch/roll, and for a lot of
people, roll is a little on the sketchy side.

Now we have twenty, twenty-five years of code and resources that make use of
quaternions. In some ways, game development is incredibly hide-bound and
conservative, and for the most part eschews rigid correctness for performance,
convenience, and a loosey-goosey good 'nuff feel.

~~~
edflsafoiewq
He's not actually proposing any change. He just gives a different construction
of the usual quaternions.

------
WAHa_06x36
Isn't the only difference between rotors, as defined in this article, and
quaternions the sign of the second 3d component?

And this only happens because the planes are defined as "xy", "xz" and "yz",
rather than the more consistent "xy", "yz" and "zx"?

If you just changed the definition of the planes at the start of the
derivation, it seems you would end up deriving the exact same operations as
you would use with quaternions? I'm not sure if there is a good argument for
not doing that.

------
amai
Let's also remove bivectors and instead use skew-symmetric matrices (
[https://en.wikipedia.org/wiki/Skew-
symmetric_matrix](https://en.wikipedia.org/wiki/Skew-symmetric_matrix) ) . The
modern matrix notation is so much more powerful and flexible than all those
19th century inventions like complex numbers, quaternions, bivectors, dual
numbers, ... that we should really stop teaching all those old confusing
stuff.

------
adam-a
This is a very cool article which has left me wanting more. It seems to stop
just short of the end though, there is no section to actually explain the
component values in a rotor, or an interactive diagram deconstructing the
component parts of a rotor. Or did I miss it?

I'd also be really interested to see some more applications. I wonder what
rotor interpolation looks like for example? I know I've had problems with
quaternion interpolation in the past.

------
wbl
Yes, the even Clifford algebra is the quaternions. So what?

------
nbulka
"We just accept their odd multiplication tables."

What is odd about the quaternions' multiplication tables? Is it the fact that
the commutative property of multiplication is violated? For the sake of
argument, let me assert that it is.

What if at the highest level of abstraction x * y had no obligation to equal y
* x?

~~~
timerol
It is definitely not that, since the article shows that a^b = -b^a. I suppose
that it's the choice that ij = k as opposed to -k?

I'm not sure, but the article's implication that nobody else cares why things
work to be distracting and insulting.

> Personally, I have always found it important to actually understand the
> things I am using.

------
randName
I wonder if this has anything to do with the 4D game that he is working on. Do
quaternions work in 4D space?

~~~
gliese1337
Yes, it does; and no, they don't.

~~~
cygx
But they do? A 4d rotation can be decomposed into a left-isoclinic and right-
isoclinic rotation, which in turn can be represented by left- and right-
multiplication with unit quaternions.

~~~
gliese1337
That's hardly the most straightforward or intuitive decomposition. In
particular, it makes simple monoplanar rotations overly complicated, in
exchange for making isoclinic rotations super simple--while rotors handle
monoplanar rotations entirely naturally, with an obvious extension to
isoclinic rotations. And monoplanar rotations are a much nicer primitive to
work with.

------
bwidlar
Geometric Algebra in 2D - Fundamentals and Another Look at Complex Numbers:

[https://www.youtube.com/watch?v=PNlgMPzj-7Q&list=PLpzmRsG7u_...](https://www.youtube.com/watch?v=PNlgMPzj-7Q&list=PLpzmRsG7u_gqaTo_vEseQ7U8KFvtiJY4K)

------
thisrod
I like this as an introduction to exterior algebra. It would be nice if the
article mentioned the Hodge star, and explained why you can identify any form
with a vector in 3D, even when it might be clearer not to.

------
skywal_l
Is the outer product the same thing as the exterior product? Wikipedia gives
different definitions. That's why I was a little confused by the article
initially. Something to keep in mind.

------
OliverJones
As we kiss these quaternions goodbye, let's remember how they came to be, and
their role in building the discipline: Ivan Sutherland's early hardware
graphics pipelines.

------
QuesnayJr
This is the exact kind of clickbait title that HN normally changes to
something less inflammatory. Every time I see the title I feel my blood
pressure going up.

------
mcphage
I'm confused—the author keeps referring to rotations. The very first sentence
is "To represent 3D rotations graphics programmers use Quaternions", even. But
I don't think you don't need quaternions to represent 3D rotations. You need
quaternions to represent translations, because translations aren't linear
functions in 3D. (To be a linear function, v * 0 = 0, but that isn't true for
translations). My understanding was that the extra dimension was to be able to
represent translations. Am I mistaken?

~~~
matt-noonan
Yes, you are mistaken. You need 3 dimensions to represent a 3D rotation (2 for
picking an axis, plus one for picking an angle). To represent translations and
rotations together, you need 6 dimensions.

This also shows that the talk of needing to visualize 4d to understand
quaternions is disingenuous. The formula for using a quaternion to rotate a
vector is q _v_ q^-1, from which it is immediate that changing the length of a
quaternion does not change the rotation it represents. So you can just deal
with unit-length quaternions, which form a 3D space.

~~~
mcphage
Hmm, I seem to be mixing up using 4d linear operations (ie, a 4x4 matrix) to
represent translation, rotation, scaling, etc, with their combinations, with
representing a rotation itself. Thanks for your help—I'll dig more into this.

------
Zenst
Bit like arguing that another keyboard layout would be better and it would if
your starting from scratch, but people tend to go with what they know and that
propergates as accepted and good enough, a standard. Hence, whilst there are
better layouts for keyboard, we still have QWERTY.

Much the same with argument here, sure GA would be better, and maybe that may
well come about, but alas quaternions are somewhat known by the many over the
few and a bit of a QWERTY situation plays out.

------
martin-adams
I have no experience in this area. Would making a change like this inside a 3D
Engine have any impact on performance?

~~~
CrazyStat
No, they're mathematically exactly the same. Just a different way of thinking
about the same mathematics that the author argues (probably correctly) makes
more intuitive sense.

~~~
bordercases
The development environment would have to be set up such that the part of the
language that uses GA primitives could be efficiently transpiled into their
corresponding matrix abstractions to prevent loss of performance on the GPU at
runtime.

~~~
earenndil
It's unclear that you really need to convert to matrices before sending off to
the GPU. [1] finds that quaternions are faster; I find that questionable (does
it scale?), but it shows that the two are comparable.

1: [https://tech.metail.com/performance-quaternions-
gpu/](https://tech.metail.com/performance-quaternions-gpu/)

------
danmg
Those who don't understand quaternions are condemned to reinvent it, poorly.

I work in a research field that uses rotations heavily, and trying to use
things like Euler angles (with 4 or 5 competing representations) and axis
angles has created nothing but confusion among people. If people used
quaternions from day one, it probably would have saved, cumulatively, the time
of several dozen phds.

~~~
jessaustin
What research field is this? Why hasn't one of the researchers made the
conceptual leap you propose?

~~~
danmg
It has to do with metallurgy. Some people do use them, but most work is done
with euler angles.

------
playing_colours
What is a good book you can advise for someone with maths background to dig
into GA?

------
duke360
quaternions (<3) are extremely useful and not so hard to learn as other have
pointed out. it's just a matter of lazyness and intesrest in solving a problem

~~~
wccrawford
Learning to _use_ Quaternions is easy. Learning how they work is much, much
harder.

Likewise, IMO, learning to use Rotors is easy, but learning how they work is
much harder... It's just that it's easier than learning how Quaternions work.

And, also IMO, you don't need to know how either of them work to use them in
gamedev. It's fine to use a library that understands them and just continue
making the important parts of your game.

~~~
K0SM0S
> _“It 's fine to use a library that understands them and just continue making
> the important parts of your game.”_

Oh that's indeed absolutely what a _game dev_ should do.

A 3D engine dev however, might do well to eat the math leading to the
understanding of quaternions, and by extension Clifford algebras (the
underlying/original theoretical structure leading to geometric algebra). You
get to understand how particular variations in _n_ -dimensions of this
structural framework are isomorphic to all numbers like R, C, H and much more.
(hyperbolic! dual!)

It really paints a whole arch-picture, a meta-framework to unify _all possibly
kinds of numbers_ in one's mind (including the geometry of these numbers and
ring operations, with a 1:1 equivalence between geom and algebra).

Note that this is why, I think, some strong proponents of GA (which I find
myself agreeing with in that regard) would have it enshrined in K-12 education
in lieu of linear algebra — because the intuition of GA is really great /
second-to-none, and _intuition_ is _all that most math students in high school
will ever retain_ afterwards (they won't do math again, ever, not really). The
argument being that people who need _more_ (from linear algebra for
calculations notably) can learn that complicated and non-intuitive stuff
_later_ (university), building on top of a good base intuition nurtured in GA
/ Clifford.

So, the 3D engine maker, people in robotics, anyone working with spatial
representations of any kind (even abstract, like research with multilinear
models) would do themselves a fantastic favor for a lifetime to learn these
topics. It's a no-brainer, really, from the other side.

It's _delicious_ math!

------
pjbk
Reading some comments here...

* GA provides some nice savings when it comes to rotor/3D calculations, provided that the underlying data structures and architecture supports them. Check out the publications by Dietmar Hildenbrand and his team for several examples:

\-
[https://www.researchgate.net/profile/Dietmar_Hildenbrand](https://www.researchgate.net/profile/Dietmar_Hildenbrand)

* Quaternions start to exhibit several limitations when dealing with complex objects, even in 3D. It provides just the necessary structure to store quadrature information to avoid the "gimball lock" issue, for example. However the fact that it collapses the scalar with the pseudoscalar presents several problems again in calculations with dual quaternions and higher dimensions (projections, for once), and it's not much different from the hurdle of having to discriminate axial and polar vectors in Vector Calculus. The main issue is that its handedness doesn't scale well and has problems capturing the geometric nature and physics of the world in several dimensions (ie symplectic geometry).

* IMHO the real usefulness of GA is that, as it name implies, it's an algebra. That is what Clifford, Ball, Lie and Klein realized while extending the work of Grassmann on exterior algebras, screw theory, vector spaces and differential forms. Matrices, quaternions and some forms have awkward behaviors when they are treated symbolically as algebraic objects, being "leaky" on information or having singularities just because they are not the best representation. GA fixes that allowing you to formulate problems symbolically, and then you can almost blindly solve the equations with high confidence that the result will be sound. You can then convert the objects back to your favorite representation. For good examples, check out Terje Vold papers on:

\- Rigid body dynamics:
[https://www.researchgate.net/publication/241273951_An_Introd...](https://www.researchgate.net/publication/241273951_An_Introduction_to_Geometric_Algebra_with_an_Application_in_Rigid_Body_Mechanics),
and

\- Electrodynamics:
[https://www.researchgate.net/publication/245345681_An_introd...](https://www.researchgate.net/publication/245345681_An_introduction_to_geometric_calculus_and_its_application_to_electrodynamics))

[Note: Watch out for some typos]. For comparison, take a look at
Featherstone's 6D Spatial Vector representation, which is similar to screws
and I think shows the best you could do with Vector Calculus objects:

\-
[http://bleyer.org/files/A%20Beginner's%20Guide%20to%206-D%20...](http://bleyer.org/files/A%20Beginner's%20Guide%20to%206-D%20Vectors%20-%20Feathersone%20\(IEEE,%202010\).pdf).

------
alpineidyll3
The author is missing a huge very real advantage of quaternions, that they are
smooth functions of thier parameters and don't suffer from gymbal lock
singularities. All 3d representions do, as can be shown with the math this guy
is too lazybrained to do.

That really matters for defining smooth paths, quaternions simply have the
right topology and rotations don't.

~~~
eigenspace
The author is using geometric algebra to create mathematical objects with all
the same properties as quaternions, but to explain and understand them in a
more comprehensive, sensible way. These things have all the same rotational
properties as quaternions.

In particular, he’s explaining that quaternions are not vectors, they’re
actually oriented planes and showing how their multiplication rules arise in a
way that’s not ‘out of thin air’.

