
Quaternions: the Strange Numbers That Birthed Modern Algebra - rbanffy
https://www.quantamagazine.org/the-strange-numbers-that-birthed-modern-algebra-20180906/
======
TipVFL
Quaternions recently made me look pretty smart.

I was consulting at a company that's developing a VR real estate app, and the
first thing I did was check to see whether they were calculating their
rotations with quaternions.

It was easy to do, I just looked straight up and then turned my head to the
right. My view rotated to the left, and I almost vomited. I immediately ripped
the headset off and said, "You're using euler angles to calculate rotations,
you need to use quaternions."

I felt pretty good about finding the biggest flaw in their system in 3
seconds.

~~~
a-dub
Was it because of
[https://en.wikipedia.org/wiki/Gimbal_lock](https://en.wikipedia.org/wiki/Gimbal_lock)
?

Apollo 11 engineers made the same mistake. :)

~~~
skykooler
For Apollo, it wasn't so much a "mistake" as a conscious decision to save
weight. The Gemini IMU used 4 gimbals, and so avoided the issue entirely.
Apollo dropped the weight of the extra gimbal and instead required the pilots
to avoid flying in certain orientations.

------
calebh
I've found that the easiest way to understand quaternions is by visualizing
them as scaled "look" or "orientation" vectors.

For example, if an airplane is oriented in the direction (x,y,z) at a rotation
θ around that axis, then its rotation in quaternion form is cos(θ/2)+x
sin(θ/2) i + y sin(θ/2) j + z sin(θ/2) k

Notice that the multiplications involving x, y, and z are just scaling the
vector.

The other important thing to realize is that sin(θ/2) is greater than or equal
to zero in the interval [0, 2*pi]. So a quaternion is just a look vector where
the magnitude of the vector is determined by the rotation around the look
vector axis.

See this page for a useful picture:
[http://www.chrobotics.com/library/understanding-
quaternions](http://www.chrobotics.com/library/understanding-quaternions)

~~~
th0ma5
Sort like monads I imagine as soon as you understand it you lose the ability
to explain. I have given up "understanding" them and just try to understand
when and where to use them.

~~~
Koshkin
That's OK! Do you think you _really_ understand the natural numbers?

~~~
posterboy
That's a good question, actually. I'm Not OP, I'm sure OP "understands" them
as much as anyone does. But considering that the most common definition is an
incomplete extrinsic definition by example, _N = {1, 2, 3 ...}_ , I'd argue
that in principle no complete extrinsic definition can be given :) That's more
than a solipsism, because any number has inherent properties that make it
different from all the others, even if these properties might be equal up to
isomorphism with "n'th successor to zero", because then the system of
isomorphisms is in question, begging the question ...

Whereas, if you know the intrinsic definition by the axioms, you know the
definition, not the numbers. Big difference that is.

I'm keen on a distinction between numbers and forumals. If you take binary
numbers and succ(), you have 0, 1 and an infinity of formulas. In my book
that's only two natural numbers. We commonly change base to represent eg. 16
as 0x10 - or 1000 as 1k, requiring additional figures. Figure, number -
potato, potato.

~~~
cannabis_sam
>I'm keen on a distinction between numbers and forumals.

What’s the operational advantage of this approach? I feel like it would wreck
havoc with fundamental tools like mathematical induction..

~~~
posterboy
The difference between f(x)=...=0 and x=2, e.g. is quite huge for a lot of
college students. The distinction between constants, operators and formulas is
quite explicit in algebra. It seems to be a natural distinction to make. One
advantage, I guess, is that a formula can be wrong, but a number can't, which
is why proof by induction works at all.

~~~
joel_ms
How would a proof by induction work with only two natural numbers?

------
Twisol
I'm happy to see 3Blue1Brown's most recent video [0] get a mention in this
article! He does a great job of explaining quaternions though visual
intuition.

(I do think simply calling Grant a "math animator" is selling him a bit short.
He's a true educator in every sense; animation is just one of the (very
effective) learning aides he uses.)

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

------
adzm
My first interaction with quaternions was by applying the same principles used
for Julia fractals, creating really fascinating artistic renders. The hardware
was incredibly slow back then, so now I'm interested in experimenting again to
see how this could be implemented in a shader.

[http://paulbourke.net/fractals/quatjulia/](http://paulbourke.net/fractals/quatjulia/)

The simple results above may just look like three dimensional blobs of taffy,
but different rendering methods create some stunning effects. Additionally
animating variations of these fractals is mesmerizing.

[http://www.bugman123.com/Hypercomplex/](http://www.bugman123.com/Hypercomplex/)

Hypercomplex fractals are simply beautiful.

------
eximius
Alright, tomorrow I want someone to count how many times we see the phrase
"the easiest way to understand quaternions is ..." on here.

~~~
Terr_
I don't think that's a bad thing -- it's people trying to test their mutual
understanding.

Here, destroy my inexpert one, and maybe I'll learn something: "It's like
describing how to twist a ball, first with the direction used to spear it with
a rod, an then how much to twist."

~~~
Twisol
I rather inelegantly attempted to describe this as "a twisty and a pushy" to a
friend today, while mimicking the animation with my hands. There is no work-
appropriate way to do this. :|

------
bediger4000
At the very least, you should open this web page just to see the weird
rotating cube with ribbons on all 4 faces animation. I'm not sure if there's a
visual trick there or not.

~~~
Sharlin
There's no trick. It's really unintuitive but it works.

~~~
max_likelihood
Seems like the top and bottom ribbons would work. But the ribbons on the side
get a kink every 2 rotations that the animation sort of sweeps under the rug?

~~~
jacobolus
They get a twist, but then loop around the cube, which undoes the twist. You
can see their full orientation throughout the animation. (Or try getting your
own cube and ribbons and try physically turning it to see for yourself.)

~~~
Maybestring
You can see the key behavior by fixing one end of a belt, and moving the free
end.

You should find that there is a way to apply and remove double twists in the
belt without twisting the free end.

------
codesushi42
Numberphile's explanation of Quaternions is the simplest I have seen so far:

[https://www.youtube.com/watch?v=3BR8tK-
LuB0](https://www.youtube.com/watch?v=3BR8tK-LuB0)

Quaternions are very important to know if you are doing any kind of 3D math.
For instance, game programming or SLAM for robotics.

------
thedaemon
As a 3d character animator I try to use Quaternions on very few bones, the
problem with Quaternions is not being able to edit the curves as a 1 to 1
understanding of the axis. I mainly use the Quaternions for IK handles and the
Root bone, the things that will rotate more than 360 degress.

~~~
mkl
> the problem with Quaternions is not being able to edit the curves as a 1 to
> 1 understanding of the axis

Can you expand on this? What is the curve representing, and which axis do you
mean?

~~~
kilpikaarna
Not the GP, but by axis they mean XYZ euler angles. In 3D animation software
you typically have a set of curve graphs that show transformations vs time,
that allow the animator to tweak timing, ease in/out of keyframes etc. If your
object has its rotations animated as a quaternion you effectively lose this
functionality, because the individual XYZW components of the 4D rotation don't
correspond to anything intuitive in 3D space. So typically you want to keep
your rotations in euler angles except in the special cases when you run into
gimbal lock etc.

~~~
mkl
Okay, let's see if I have this right. The rotations are animated by
manipulating the graphs of three functions of time, the values of which are
the amounts of rotation around each coordinate axis?

The only rotation animations I've made have been done with code.

~~~
kilpikaarna
Pretty much. Usually you do the rough animation by manipulating the objects in
the 3D viewport (with the manipulator using euler angles even in the cases
where the angles are then converted to and stored as quaternions) and marking
keyframes. The graph view is then useful for tweaking the interpolation
between keyframes, minor adjustments, copying and pasting keyframes and such.

The graphs are time on X against rotation/translation/scale amount on Y, yes,
with separate graphs for each axis.

------
adamnemecek
Ive been recently studying dual quaternions which are even crazier

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

They are THE formalism for representing translation and rotation since they
interpolate super nicely.

~~~
gugagore
You can just interpolate translation and orientation each individually
(translation using linear interpolation, since it's an affine space, and
orientation using SLERP or the matrix exponential and logarithm), and you
should get the same thing as dual-quarternion interpolation.

~~~
adamnemecek
Slerp is quaternionic interpolation.

~~~
gugagore
It's not dual-quaternion anything, though.

(Also you can implement it with matrix logarithms and exponents, no unit
quaternions necessarily needed)

~~~
adamnemecek
Can you look into it first? Yes you can but dual quaternions are more suited
for this.

~~~
gugagore
I have looked into it, that's why I felt comfortable replying in the first
place! ;)

Can you explain why dual quaternions are more suited and for what? I can
understand the appeal of having "one number" to represent a rotation and
translation. But the interpolation they provide is no different than if you
interpolate the rotational and translational components independently, right?

By the way, the 2D analog of dual quaternions is dual complex numbers. They
let you encode a translation and rotation (and scaling) in 2D, just as the
dual quaternions do for 3D.

One thing that bothers me about dual quaternions, and you may have an answer
to this, is that there's an 8th term that doesn't seem to buy you anything:
the epsilon term (not multiplied by i, j, k). It's an 8-dimensional
representation, whereas a quaternion + translation is a 7-dimensional
representation.

For more information:
[http://www.euclideanspace.com/maths/algebra/realNormedAlgebr...](http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/other/dualComplex/)

[http://www.euclideanspace.com/maths/algebra/realNormedAlgebr...](http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/other/dualQuaternion/index.htm)

~~~
adamnemecek
The separation can be a problem if I want to for example do a Fourier
transform.

~~~
gugagore
A Fourier transform of what? If you have a reference, I'd love to learn more.

~~~
adamnemecek
Hey can you email me? I’d like to continue this convo. My email is in my
profile.

------
fb03
Where could one learn quartenion math?

For educational purposes, I want to generate a 3d rotating cube on the screen
without any help from 3d kits like OpenGL and etc (I want to learn all the
math there is to do this without any help, only rastering).

Thanks in advance.

~~~
codesushi42
You will need more than quaternions to get a rotating cube working without
OpenGL. You would need some kind of basic lighting for this to work.

If you really want to build a 3d engine from scratch without OpenGL, I suggest
checking this book out. It was written in the mid 90s and explains how to
write a simple 3d engine in DOS.

[https://archive.org/details/BlackArt3DEBook](https://archive.org/details/BlackArt3DEBook)

~~~
codesushi42
Well, I suppose you could create a wireframed cube without any lighting...

But the above material is much more interesting.

------
msla
And if you take quaternions further, you end up with something you can
generalize to any number of dimensions, which also unifies algebra and
geometry in very nice ways: Clifford algebra.

[https://slehar.wordpress.com/2014/03/18/clifford-algebra-
a-v...](https://slehar.wordpress.com/2014/03/18/clifford-algebra-a-visual-
introduction/)

> Here we see the hierarchy of Clifford Algebras each with its own
> characteristic pattern of components, that appear in numbers corresponding
> to Pascal’s triangle. Two-dimensional clifs, Cl2 (the even sub-algebra) are
> mathematically isomorphic to complex numbers. Three-dimensional clifs, Cl3
> are isomorphic to Pauli matrices used to model subatomic particles. Cl4 is
> isomorphic to Dirac matrices that model relativistic subatomic particles.

All of that assumes every element of the metric signature has the same sign;
that is, the dot product of any basis vector with itself is always positive
for all of them or negative for all of them. If you pick one dimension to have
a sign opposite the others, that dimension is your time dimension and you're
now in Minkowski space. The consequences of doing that is literally the
entirety of Special Relativity.

If you construct a Clifford algebra in Minkowski space, that's Spacetime
algebra:

[https://arxiv.org/abs/1411.5002](https://arxiv.org/abs/1411.5002)

> We present a comprehensive introduction to spacetime algebra that emphasizes
> its practicality and power as a tool for the study of electromagnetism. We
> carefully develop this natural (Clifford) algebra of the Minkowski spacetime
> geometry, with a particular focus on its intrinsic (and often overlooked)
> complex structure. Notably, the scalar imaginary that appears throughout the
> electromagnetic theory properly corresponds to the unit 4-volume of
> spacetime itself, and thus has physical meaning. The electric and magnetic
> fields are combined into a single complex and frame-independent bivector
> field, which generalizes the Riemann-Silberstein complex vector that has
> recently resurfaced in studies of the single photon wavefunction. The
> complex structure of spacetime also underpins the emergence of
> electromagnetic waves, circular polarizations, the normal variables for
> canonical quantization, the distinction between electric and magnetic
> charge, complex spinor representations of Lorentz transformations, and the
> dual (electric-magnetic field exchange) symmetry that produces helicity
> conservation in vacuum fields. This latter symmetry manifests as an
> arbitrary global phase of the complex field, motivating the use of a complex
> vector potential, along with an associated transverse and gauge-invariant
> bivector potential, as well as complex (bivector and scalar) Hertz
> potentials. Our detailed treatment aims to encourage the use of spacetime
> algebra as a readily available and mature extension to existing vector
> calculus and tensor methods that can greatly simplify the analysis of
> fundamentally relativistic objects like the electromagnetic field.

More prosaically, it allows you to write all of the Maxwell equations in a
single equation.

[http://www.av8n.com/physics/clifford-
intro.htm](http://www.av8n.com/physics/clifford-intro.htm)

------
choonway
Seems like a wierd article trying to support octonions. I've graduated from
quaternions using Lie Algebra/Groups (not that I understand them completely)
but I find it much more general that it handles translations in a much better
fashion.

------
jkabrg
If you like quaternions, you should check out the split-quaternions. They're
equivalent to the 2x2 matrices, but help you understand them better by using
analogies to the highly familiar and intuitive quaternions.

------
rjdagost
I get why Euler angles are not ideal (gimbal lock). But what are the
advantages of quaternions over rotation matrices?

~~~
lodi
(From the point of view of graphics programming.)

The advantage/disadvantage of a 4x4 matrix (i.e. homogenous coordinates) is
that you can describe the full transform--position, rotation, scale, and skew
--in one go. If you only care about rotations, then using quaternions is less
multiplication. Plus quaternions sidestep any issues with unwanted scale/skew
if you're dealing with rigid-body objects.

