
Let's remove Quaternions from every 3D Engine - Glench
http://marctenbosch.com/quaternions/
======
corysama
Tangential: Back in 2000 there was some debate about dropping quaternions in
favor of a set of equivalent operations on plain matrices.
[https://www.gamedev.net/articles/programming/math-and-
physic...](https://www.gamedev.net/articles/programming/math-and-physics/do-
we-really-need-quaternions-r1199/) The debate petered out when the proponents
finished optimizing their implementation and found they had produced exactly
the same code as the existing quaternion implementations. The only difference
was the approach used to derive it.

~~~
lmitchell
Thank you for posting this, I found it both very enlightening and a pretty fun
internet-drama read :D

Interesting that the original complaint of that article/thread and this one
are both the same - ie. quaternions are 'too hard to understand', and people
'use them without knowing how they work'. With this being posted so soon after
[https://news.ycombinator.com/item?id=18310788](https://news.ycombinator.com/item?id=18310788)
, I feel like that complaint is less valid now than it ever has been, but it's
kind of interesting to think about why quaternions in particular draw so much
fire when, honestly, I found matrices to be equally challenging at first. Is
it just an education thing, since matrices are generally taught much earlier?
Or is there some intuition in matrices that isn't present in quaternions? Both
of them seem to be just 'do this math, then magic happens' unless you think
about them a fair bit, and that was pretty challenging for both the first time
round imo.

~~~
marctenbosch
I think matrices are easier for people to visualize because they can think
about them as a vector frame and coordinate transformations.

Quaternions are seen as this abstract 4D space somehow containing 3D space
transformations, and people have a much harder time visualizing 4D space. I do
not think spending a lot of time trying to visualize this 4D space, like this
video does, is the right way to go. Rotors make that method obsolete.

~~~
jacobolus
To be honest the hardest part is not understanding single rotations, but
understanding how rotations compose.

Thinking about a scalar + bivector as the quotient of two vectors or as the
composition of two reflections is easy enough. But that still doesn’t yield a
solid understanding of how rotation works – 3D rotation is subtle and tricky,
even for people who have pretty good spatial reasoning and a lot of experience
working with solid geometry / 3D design.

I have been thinking about the best interactive diagram(s) for giving people a
good intuition about that for a long time, and I have some ideas but I still
haven’t implemented anything and I’m not sure how well it will work.

------
eigenspace
I do love Geometric Albegra and hope it gets further adoption. In my field
(physics), the project of moving to geometric algebra currently looks hopeless
due to the inertia of other formalisms and lack of interest from established
physicists.

The real shame is that the best opportunity to introduce physicists to
geometric algebra was a hundred years ago when we were first discovering
spinors. First the Pauli algebra and then the Dirac algebra. If physicsts at
the time had been made aware of the geometric algebra approach to these
things, I think it could have been an appropriate motivation to switch to
geometric algebra. Instead, people came up with matrix representations of the
Pauli and Dirac algebras and the field is stuck using those and saying "meh.
Good enough."

~~~
impendia
Can I ask you (and keldaris) what precisely you mean by geometric algebra, and
how you would propose to teach it?

I'm a math professor. To me "geometric algebra" refers to any use of geometry
in mathematics to illuminate algebraic principles. There are very very many of
these -- this article illustrates one good example. I try to incorporate
intuition from geometry into my teaching whenever possible.

It seems that the two of you are referring to some _particular_ unifying
framework, and/or set of definitions and notation. Could I ask you to
elaborate on what you mean?

Thanks.

~~~
dahart
Geometric algebra has a definition that is more specific than any use of
geometry to teach Elementary Algebra on real numbers.

[https://en.m.wikipedia.org/wiki/Geometric_algebra](https://en.m.wikipedia.org/wiki/Geometric_algebra)

[https://en.m.wikipedia.org/wiki/Clifford_algebra](https://en.m.wikipedia.org/wiki/Clifford_algebra)

For teaching geometric algebra, there are curricula and textbooks available...

[http://geometry.mrao.cam.ac.uk/home/introduction-to-
ga/](http://geometry.mrao.cam.ac.uk/home/introduction-to-ga/)

[https://arxiv.org/abs/1205.5935v1](https://arxiv.org/abs/1205.5935v1)

[http://www.faculty.luther.edu/~macdonal/GA&GC.pdf](http://www.faculty.luther.edu/~macdonal/GA&GC.pdf)

[http://assets.cambridge.org/052148/0221/sample/0521480221WS....](http://assets.cambridge.org/052148/0221/sample/0521480221WS.pdf)

[http://geometricalgebra.org/downloads/ga4cs_toc.pdf](http://geometricalgebra.org/downloads/ga4cs_toc.pdf)

[https://www.amazon.com/dp/0792355148/](https://www.amazon.com/dp/0792355148/)

~~~
impendia
Thanks, I'll have a look!

This looks a bit too high-level to inform my undergraduate teaching, but
certainly _I_ could learn something from this.

------
modeless
Hmm, the word "interpolate" does not appear in the article. One of the main
applications of quaternions in games is interpolating rotations. Does this
representation interpolate well?

Also, I've seen several articles trying to convince me that alternative
transformation representations like these are better, but I haven't seen much
code. Has anyone written a library using these concepts that could replace a
traditional vector math library like
[https://glm.g-truc.net/](https://glm.g-truc.net/) for games?

~~~
marctenbosch
Yes, anything you can do on quaternions you can do on rotors. (Updated the
article)

I have not seen a clean version of the code online but it is almost the same
as for a quaternion.

~~~
scotty79
Great post although it made me hungry for explanation what are the actual
implementation differences between rotors and quaternions because I got the
impression that we use exactly same real numbers to do exactly same things. We
just imagine basis of this transformation space not as some 4 orthogonal
vectors, just 3 orthogonal unit planes plus one real number for scaling.

Those bivectors just explain (incredibly, amazingly well) what quaternions are
and why they have properties they have. It doesn't seem to change how you
crunch the numbers to get what you want.

...

It's really great that you wrote that post. I feel like for the first time I
truly understand rotations in 3D and know why I felt something fishy was going
on with results of vector product and expressing rotations with them.

~~~
marctenbosch
99% of the time this is true.

------
ajkjk
Texts on GA seem to start out saying "we're going to replace vector analysis
with something intuitive and natural and eloquent and..." and then immediately
introduce the "geometric product", which is neither intuitive, eloquent, or,
as far as I can tell, natural. Its properties are found via formula-wrangling,
and the results you get from it seem to just magically work, rather than being
intuitive.

Bivectors in general are conceptually great; it's just the geometric product
which I think is conceptually flimsy. And it's surprisingly hard to compute or
make sense of the geometric product in general which is why the writer of the
first book cited on the OP wrote "I do not think it possible to give a quick
definition of the general geometric product."[1]

As far as I can tell 95% of the usefulness of geometric algebra is the
usefulness of the _wedge_ product ∧, which is absolutely under-appreciated and
appears in loads of places in disguise (for instance, the determinant of a
matrix is the wedge product of all of its rows or columns together).

The last 5% of the usefulness of GA comes from using the geometric product in
vector-rotation via -ava^-1, which is admittedly very useful (it's why physics
and computer graphics represent rotation this way, albeit in disguised forms
like Pauli matrices and quaternions.) You can express that form without the
geometric product, but I haven't found a way that strikes me as very elegant.

I don't mean to condemn GA - I think what it's doing is massively important.
The mathematical language for vector analysis deficient compared to what we
could be using, and a lot of things are more intuitive and natural in better
language. I just suspect that the, uh, ideal form of this stuff will look
slightly different than GA, and might not include the geometric product at
all, but will definitely include the wedge product absolutely everywhere.

(I've spent a lot of free time trying to figure this out but I don't really
have a compelling result yet. I've been meaning to try blogging about it,
though, since it's basically my favorite thing to study.)

[1] [https://math.stackexchange.com/questions/444988/looking-
for-...](https://math.stackexchange.com/questions/444988/looking-for-a-clear-
definition-of-the-geometric-product)

~~~
jacobolus
The geometric product is super useful and important! (As well as much nicer to
work with when doing algebraic manipulation.)

In particular, it is what lets you take products, inverses and quotients
(assuming the denominator is non-null) of arbitrary vectors.

> surprisingly hard to compute

Hm? No it isn’t....

Several times in the last few years I have done several pages of complicated
calculations in terms of coordinates or matrices, where the intermediate steps
were basically an indecipherable mess of symbols, and then sat down, really
thought about what I was doing for a while, and re-written it using GA
language and ended up simplifying my work down to a few lines of simple
algebraic manipulations, where I could typically then give a nice geometrical
interpretation to each step.

If you want to compute the geometric product using concrete numbers in terms
of a basis, then it is straightforward to write the code (or work through by
hand).

What is hard is not the geometric product. What is hard is geometry! There is
a lot of depth and subtlety, and it takes years to really learn your way
around. That is not the fault of the language though; there is a certain
amount of irreducible complexity involved.

Personally I would love to get some people together and try to write a high-
school-accessible geometry / vector algebra book using GA language. It would
be a few years of hard work, because figuring out the right order for the
curriculum, the right types of problems to build intuition, which tools to
include or leave out of an introductory book, how to best show the work for a
whole collection of worked examples (ideally with some interactive computer
diagrams), and so on.

~~~
ajkjk
It is easy to compute on vectors. It is possible, but complicated and
unintuitive (I have written code to do it in the past), to compute it on
multivectors.

I'm arguing in favor of _most_ of GA's language. I just keep finding that the
wedge and inner product parts are fantastic, and the geometric product part
isn't. And I think the reason people keep finding GA appealing is because they
didn't have the wedge product before, so having _that_ in their conceptual
toolkit fixes a lot, while having the geometric product doesn't fix much on
top of it. Anyway I've studied GA a lot and I still have basically no idea
what 'AB' _means_ when both are arbitrary-grade multivectors, and as far as I
can tell most sources don't even try to explain it.

~~~
jacobolus
I’m telling you that after a few years working with the geometric product a
whole bunch, the wedge product really doesn’t cut it.

> _I still have basically no idea what 'AB' means when both are arbitrary-
> grade multivectors_

Any mathematical language (or any natural language) can express a bunch of
nonsensical and useless things. What is the sine of the square root of the
logarithm of the tangent of some polynomial applied to a scalar? Who knows?!

You can certainly make up nonsensical expressions using matrices, differential
forms, etc.

In a concrete problem, sometimes you have to think a bit to figure out what
the geometrical meaning is of a particular multivector, but if the problem
came out of a physical situation, I haven’t yet found a case where I couldn’t
explain it.

Your multivector might be an electromagnetic field. It might be a rotor. It
might be a representation of a sphere in the conformal model, ...

~~~
ajkjk
To be clear, I don't think the wedge product is sufficient either; I just
think it's the real reason most people end up finding GA to be appealing.

I think there's work to do to clean the whole space up. Particularly, the
wedge product is a 'join' or 'union' operator (amusingly, it has the wrong
symbol). The 'meet' operator is not widely known but should probably be
equally prominent. I haven't figured out for myself where the other holes are
yet.

~~~
jacobolus
You might enjoy
[https://arxiv.org/abs/1205.5935](https://arxiv.org/abs/1205.5935)

~~~
improbable22
As someone unable to fathom the enthusiasm for geometric algebra... at least
this defines this product: It's the sum of an inner product and a wedge
product. Acting on two vectors these give a scalar and a 2-form. Why is adding
these different objects a good idea? Don't they have different units (like, a
pure number vs meters squared)?

~~~
happy4crazy
It's analogous to the real and imaginary parts of a complex number. Does it
makes sense to add a real number and a purely imaginary number? Aren't they
different kinds of things? Yes, and yes!

~~~
twic
It would really helpful if the article had some worked examples of this
arithmetic, with actual numbers, the kind with digits and decimal points in.
Then, things like the structure of a geometric product would be absolutely
clear.

Let me have a go. I'll use an asciified version of the symbols, with * to mean
multiplication of two scalars,, __to mean raising one scalar to the power of
another, and _ to mean taking a component of a vector.

    
    
      ab = a.b + a^b
      
      a.b = a_x * b_x + a_y * b_y + a_z * b_z
      
      a^b = (a_x * b_y - b_x * a_y) (x^y)
          + (a_x * b_z - b_x * a_z) (x^z)
          + (a_y * b_z - b_y * a_z) (y^z)
      
      ab = (a_x * b_x + a_y * b_y + a_z * b_z)
         +             (a_x * b_y - b_x * a_y) (x^y)
         +             (a_x * b_z - b_x * a_z) (x^z)
         +             (a_y * b_z - b_y * a_z) (y^z)
    

So if a = (1, 2, 3) and b = (4, 5, 6):

    
    
      ab = (1 * 4 + 2 * 5 + 3 * 6)
         +         (1 * 5 - 4 * 2) (x^y)
         +         (1 * 6 - 4 * 3) (x^z)
         +         (2 * 6 - 5 * 3) (y^z)
      
         = 32 + -3 (x^y) + -6 (x^z) + -3 (y^z)
    

The dot product makes a scalar, the wedge product makes a bivector, and the
geometric product makes a scalar plus a bivector

You will note that the scalar part is much bigger than the coefficients of the
bivector part. That's because the input vectors are actually quite similar -
pointing z-by-y-z, with a little bit of x. Hence, their projection onto each
other is large, whereas the parallelogram they form is quite small (long and
thin). The dot product measures the former, the wedge product the latter.

Have i got that right?

EDIT And to clarify this:

> For any basis vector, such as the x axis, the result [of taking the
> geometric product with itself] is 1

That '1' isn't the scalar number 1, it's the scalar-plus-bivector 1 + 0 (x^y)
+ 0 (x^z) + 0 (y^z).

------
boxcardavin
I use quaternions at work (AVs) and used them in physics and astronomy in
school. The math he's talking about is darned close to the math done behind
the scences with quaternions, it's just easier to grasp because it has visual
references. Thing is, you only need to understand the math once to be able to
use any of this stuff, and there's nothing wrong with taking it for granted
after that. Either method is good enough.

Basicallt, quaternions are hard to understand but easy to use.

~~~
vanderZwan
I take easy to understand and easy to use over that any day. But hey, I also
was a teacher once so I'm probably biased here.

------
vertline3
So I have a layman's question: 3blue1brown and Ben Eater did a quaternion
visualization set of videos. And they said it was good because it avoided an
an axis lock thing that happens when x y z rotate. He said there were maybe
some errors with other models as well. So I guess the question is "does this
also not have the locking axis problem?"

I think it's called gimbal lock?

~~~
WhitneyLand
Just in case it's not obvious to all, this "axis lock thing" you speak of is
so important it could cause a plane to crash! :) (it has implications beyond
computer graphics).

~~~
sampo
[https://en.wikipedia.org/wiki/Gimbal_lock#On_Apollo_11](https://en.wikipedia.org/wiki/Gimbal_lock#On_Apollo_11)

------
outworlder
This article will take more than than I have to digest right now, but it's
definitely saved.

I have never really understood quaternions. All I knew is that I could use
that instead of euler angles, avoid gimbal lock, and would blindly use them.

~~~
WhitneyLand
I think you just described 90% of people who use them. Normally I like having
a better grasp of the underlying theory I'm applying, but somehow quaternions
seem more likely to make me think, yeah I'll eventually get around to that...
instead of diving right in as this article I believe better motivates.

~~~
outworlder
> but somehow quaternions seem more likely to make me think, yeah I'll
> eventually get around to that

Exactly. And then you forget about them because...well, it's not like this
stuff requires maintenance. Once you abstract all rotations and interpolations
away, you just use them and forget you don't really grasp _why_ they work.

------
19870213
Is this the same Marc Ten Bosch as from Miegakure [1]? Considering the
content, probably the same person.

[1] [http://miegakure.com/](http://miegakure.com/)

~~~
vanderZwan
Yes. He also made 4D Toys

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

------
chombier
I don't quite understand why the author opposes quaternions and geometric
algebra: the geometric product is almost exactly the formula for multiplying
pure imaginary quaternions (up to the real part sign).

These are just two constructions of isomorphic Clifford algebras which really
are the same thing.

~~~
eigenspace
That's not true. The quaternions are the _even subalgebra_ of the 3D geometric
algebra. They are not isomorphic. Quaternions are isomorphic to the set of
scalars and bivectors in the 3D geometric algebra but the 3D GA also has
vectors and a volume form.

This is just like how the complex numbers are isomorphic to the even
subalgebra of the 2D geometric algebra.

The geometric algebra is richer, more powerful, more generalizable and more
coherent than the quaternion algebra, all while being easier to understand
because its so physical.

~~~
chombier
I stand corrected, thanks a lot! It seems the article mostly deals with the
scalar/bivector aspect of it though.

------
onhn
I don't understand the title at all: given that there is an isomorphism, any
method of distinguishing an implementation of quaternions from the proposed
alternative is necessarily an arbitrary one.

------
beeforpork
I am not sure if I understand how to apply this to every 3D engine. A 3D
engine uses 4D matrices so that it can concatenate rotations, scaling,
translations, and perspective correction into one matrix operation using
matrix multiplication, i.e., it can represent any sequence of 3D operations in
a single matrix.

So what is the equivalent structure I'd use with trivectors to combine
arbitrary 3D transformatinos into a single operation, like every 3D engine
needs?

The linked Versor library was also not very helpful -- it has the rotate
operation on a vector, but I found no 'make rotation' and 'make translation'
and 'make frustrum' and 'apply transformation' and 'concatenate
transformation' operations.

------
adamnemecek
Dual quaternions are even better for dealing with dynamic 3D space

[http://www.chinedufn.com/dual-quaternion-shader-
explained/](http://www.chinedufn.com/dual-quaternion-shader-explained/)

~~~
eigenspace
This can be better expressed in the geometric algebra by just considering a
geometric algebra with a degenerate metric (ie. you use basis elements x̂, ŷ,
ẑ and ϵ̂ where x̂² = ŷ² = ẑ² = 1 and ϵ̂² = 0). Including factors of ϵ̂ in your
rotors now is equivalent to a dual quaternion.

This way, one gets the wonderful properties of geometric algebra and the
useful properties of dual quaternions together.

~~~
adamnemecek
GA is more general, however my claim is that the DQ space is the most useful
one. E.g. sedenion have little use right now.

Also I believe that technically they call under Clifford algebra.

------
enriquto
geometric algebra proponents are the rust strike force of mathematics

~~~
dragonwriter
Rust seems to have better (free, at least) documentation, though.

~~~
pzone
It also offers more in the way of concrete benefits.

~~~
enriquto
Not sure if you are ironic and what are you referring to by "it", but in any
case I was mocking both rust and GA.

In all seriousness, both rust and geometric algebra are really very cool; but
their proponents are so ridiculously over-enthusiastic that it is easy to get
tired of them before taking them seriously.

------
palisade
Quats can be represented with (x, y, z, w). Rotors require a vector, bivector
and angle (vec_x, vec_y, vec_z, bivec_x, bivec_y, bivec_z, theta). If you are
storing or transmitting a quaternion it consumes less space and in 3D
simulations or games a quaternion is therefore advantageous. 3D file formats
would explode in size if rotors were used. And, more network packet fragments
would be needed to encapsulate a world state update of moving objects, npc and
players. That would waste bandwidth (therefore $), cause "rubberbanding" and
increase latency.

~~~
Rusky
No. 3D rotors are represented exactly the same way as quaternions- 4 scalars.
The operations are the same as well, only the explanation is different.

~~~
palisade
Partially true, internally libraries represent the rotor as just four scalars
and can convert these to a quaternion. However, to actually make use of the
rotor to do anything useful, e.g. interpolate, which is a power quaternion
math has innately, you need to provide a lot more external information; plane
origin vector, bivector, angle. A 3D file format storing the transformations
between joints of the skeleton of a character for example would have to
provide these extra bits of information in order to store the frames to
perform inverse kinematics.

Likewise, if you needed to store or transmit spherical camera interpolations
or non-player or player character transitions over a network this information
would also have to be provided. You could perhaps do _some_ optimization, e.g.
only sometimes transmitting the origin once and then only sending the
bivectors and angles in some cases which still would waste bytes and increase
complexity. And, sometimes you couldn't so you'd have to send the whole thing.

But, with a quaternion you get this for free without any logical gymnastics
via the previous four scalars to the next four scalars between delta frames.
And, in the case of slerp only the lambda of time.

Now you _can_ argue that a rotor could be used locally and then when
storage/transmission is required you could convert to and use quaternion math
to perform the necessary interpolations and thereby get the space savings.
However, this article is specifically asking for the complete removal of
quaternions from the field of computer science.

Unless I'm misunderstanding. Though I haven't seen a code example where rotors
don't require this extra information. For example, in libvsr they have
examples that require all these pieces for each frame. However, maybe that is
an inefficient or naive implementation.

I did find this: [http://geometry.mrao.cam.ac.uk/wp-
content/uploads/2015/02/01...](http://geometry.mrao.cam.ac.uk/wp-
content/uploads/2015/02/01ApplicationsI.pdf)

Which provided a formula for rotor slerp: R(lambda) = (1.0 / sin(theta)) *
(sin((1 - lambda) * theta) * R0 + sin(lambda * theta) * R1)

If that is the case, then the bare minimum information required is still more
than a quaternion. We'd require the lambda, theta, and R0 (4 scalars), R1 (4
scalars).

~~~
jacobolus
You are misunderstanding. A quaternion literally is a scalar + bivector
(“imaginary”) rotor. We are talking about the same 4 numbers.

It lives inside a geometric algebra which also includes vectors and
trivectors, but those are not part of the rotor.

If you store a rotor as a general 3D multivector, it will have 8 entries 4 of
which are always 0; this could be done to simplify your code (then you only
need one multivector type), but is not a good idea for efficiency of
computation/transmission if you need to represent large numbers of rotations
and their transmission might be a bottleneck.

~~~
palisade
According to the formula I provided, to slerp for example, rotors require
lambda and theta. Whereas quaternions only require the lambda. Is there an
alternative I'm missing?

~~~
jacobolus
Which formula are you talking about? The arithmetic is literally exactly the
same.

“Slerp” just means follow a path on a circle at uniform speed (i.e. “use
trigonometry”). In this case, we are talking about a circle on the conceptual
unit 4-sphere. It doesn’t really matter what names we call the basis elements.

------
rafael859
I've played around a bit with geometric algebra in the past year, and I have
to say that by far the best resource (albeit a bit short) was Ben Lynn's
implementation in Haskell [0]. Unfortunately there isn't a well-written source
that explains the methods well. There are multiple ways to do things, and I
had trouble finding elegant solutions to practical problems.

[0]
[https://crypto.stanford.edu/~blynn/haskell/ga.html](https://crypto.stanford.edu/~blynn/haskell/ga.html)

------
Improvotter
I'm no game developer. But wouldn't it be important for game engines to use
the most performant approach. Is there a difference in performance when using
rotors instead of quaternions?

~~~
naikrovek
No difference in the actual math used, just differences in how you approach
understanding of the problem.

------
amluto
I read through a bunch of this, and one part seems poorly explained. There’s a
clear definition of the product of two vectors, but the result isn’t a vector
— it’s a scalar plus a bivector. Then, by magic, three vectors get multiplied!
But what does that even mean? Somehow a vector gets multiplied by a bivector,
and the result is somehow still a vector.

What’s going on?

~~~
marctenbosch
The [Aside] section of "The Reflection Formula (Geometric Product Version)
"[http://marctenbosch.com/quaternions/#h_13](http://marctenbosch.com/quaternions/#h_13)
has the answer you seek ;)

~~~
amluto
I read that a couple times. I found it unsatisfying because you are dropping
terms that happen to have a coefficient of zero without a clear explanation of
how those terms are even well formed in the first place.

I suppose this could be answered if you explicitly stated what set the
geometric product acted on. As a guess, and from skimming Wikipedia, it’s the
direct sum of scalars, vectors, bivectors, etc, up through n-vectors. So 2 +
x∧y + 3x∧y∧z is a valid output. And it’s probably straightforward to show that
the geometric product is actually defined on this space.

(Hi Marc!)

~~~
marctenbosch
Ok I understand your question better, might update the article. Like the other
commenter said, you can keep applying the geometric product more than once. To
find what happens you can just work with the basis vectors.

So, you basically have three case: x (xx) = x (1) = x -> a vector

x (xy) = x (x.y + x^y) = x (x.y) + xxy = x (x.y) + y -> a vector

x (yz) = x (y.z + x^y) = x (y.z) + xyz -> a vector + a trivector. This only
happens if the three vectors are independent, which can never be the case for
-ava

------
ru999gol
When just implementing a first person type control/viewport I found it way
easier to just use euler angles and the gimbal lock didn't really feel
unnatural to me. So I think there is something to the idea that maybe you
don't even need the complexity of quaternions at all dependent on the usecase.

~~~
outworlder
But once you are in gimbal lock, what do you do?

~~~
slavik81
Any rotation around the unaligned axis will free you. The problem with gimbal
lock for 1st person controls is mostly avoided because roll is limited and you
don't need to smoothly rotate over the poles anyways.

But, I find that I often need smooth, arbitrary rotations for other things, so
I just use quaternions everywhere. When using Euler angles as input, I
immediately convert them to quaternions.

------
tobr
It’s certainly been an intense week in the department of “explorable
explanations of how to rotate stuff in 3D”, with both this and the
3blue1brown/Ben Eater collab.

[https://news.ycombinator.com/item?id=18310788](https://news.ycombinator.com/item?id=18310788)

------
peter_d_sherman
Excerpt: "It is strange because multiplying two vectors together gives the sum
of two different things: a scalar and a bivector. However this is similar to
how a complex number is the sum of a scalar and an "imaginary" number, so you
might be used to it already. Here the bivector part corresponds to the
"imaginary" part of the complex number. Except it is not "imaginary," it’s
just a bivector, which we have a concrete picture of!"

------
moron4hire
It's completely unnecessary to understand what the individual components of
quaternions represent. All that is necessary is to build an understanding of
what the operations do for you. Do you need to understand Russell's proof that
1+1=2 to compute the tip on your bar bill, or do you just need to know what to
expect when you apply the addition operation to two numbers? Treat quaternions
as indivisible whole values as you would floating point numbers.

~~~
yiyus
I will give you an example (from my recent work) where actually knowing what
the components mean was useful.

I had to calculate misorientations between many pairs of orientations. If I
treated quaternions as a whole, I would find their quotient and then get the
angle. But since I know what the components mean, and I know I can get the
misorientation angle from just the cosine (the scalar component), and I know
that I can get this value from a simple dot product, I can easily save a few
operations to calculate every misorientation. And since I have to calculate
many of them, this change supposed a big speedup.

Black boxes are nice when learning or thinking at a high level, but if you
frequently use a black box, knowing what is inside will probably become useful
at some point.

------
grondilu
Isn't it, in the end, just a notational issue? Quaternions are unit bivectors.
Up to a slightly annoying sign change, quaternions which are noted as i, j and
k correspond to bivectors jk, ki and ij, don't they?

There should be a way to write a library that translates geometric algebra
notations into their corresponding quaternion ones, and reciprocally.

------
antpls
For the most brightest mathematicians of HN : could you relate this to
tensors?

~~~
eigenspace
Tensor algebra is fully expressible in terms of geometric algebra. If you're
itnerested, I'd reccomend Geometric Algebra for Physicists by Doran and
Lasenby.

------
platz
I thought Quaternions solved discontinuities in rotations.

------
united893
How do rotors map to euler angles?

~~~
marctenbosch
The same way quaternions do.

------
choonway
Why not use Screw Theory?

~~~
eggy
Check out this gem of a book on screw theory, geometric algebra and robotics.
I keep it on my desk it's so useful.

Geometric Fundamentals of Robotics - by J.M. Selig 1996, 2005 2nd Edition

------
aaaaaaaaaab
Also: stop conflating bivectors and vectors. E.g. the inverse-transpose rule
for transforming normal vectors needs no explanation when you treat them
correctly as bivectors, and not vectors. Same goes for torque, etc.

------
andbberger
This article reads like 'I don't understand quaternions therefore they're
bad.'

Like what - they are the objectively best representation of rotations...

~~~
eigenspace
That's not at all what the author is saying. The author actually has a much
deeper understanding of quaternions than most of their users and realizes that
they are part of a much more general and useful structure known as the 3D
geometric algebra and he advocates using that instead of quaternions.

GA(3) use objects that are isomorphic to quaternions to represent rotations
but is much more comprehensible and generalizable than quaternions.

~~~
andbberger
OK sorry, that was rash of me to say.

