
Understanding Quaternions - njn
https://www.3dgep.com/understanding-quaternions/
======
amai
Sorry to spoil the party, but this is the old 19th century way of teaching
quaternions (and also complex numbers). It is much easier to start with some
[https://en.wikipedia.org/wiki/Group_theory](https://en.wikipedia.org/wiki/Group_theory)
and then you understand that quaternions are simply matrices of a specific
form:
[https://en.wikipedia.org/wiki/Quaternion#Matrix_representati...](https://en.wikipedia.org/wiki/Quaternion#Matrix_representations)
. Quaternion multiplication is simply matrix multiplication of these matrices.
And that's it. No mysteries, this is just simple linear algebra (you do't even
need complex numbers, the real representation is enough and makes the
connection to 4d rotations manifest).

~~~
gmadsen
it shouldn't be an either or with geometry and algebra. both are valid and it
helps to know both. representing H as a matrix is certainly valid and makes
computations easier, but I dont really think that is building intuition

~~~
earthicus
The modern approach is not lacking all geometry, and the 19th century
presentation is not lacking all algebra. Any respectable treatment will
include both, the question is which makes the relationship clearer? The
abstract algebraic approach talks of 'the rotation group' which maps on to
geometric concepts as cleanly and directly as possible. Then we talk of
different parameterizations or representations of this group, with the unit
quaternions being the 'double cover' of the rotation group (which gives rise
to the primary difficulty in understanding them - that a rotation by 360
degrees reverses orientation, and 720 degrees returns us to where we started).

I think the modern approach is much clearer - the geometric ideas appear more
directly, and the algebra is far less messy.

~~~
edflsafoiewq
> I think the modern approach is much clearer - the geometric ideas appear
> more directly, and the algebra is far less messy.

Can you show us an example?

------
foobarbecue
In case you missed it, 3B1B has a brilliant video introducing quaternions:
[https://youtu.be/d4EgbgTm0Bg](https://youtu.be/d4EgbgTm0Bg)

~~~
raffael-vogler
His videos are really incredibly intuitive and well-made. He deserves an award
for his channel.

~~~
foobarbecue
Yep, and all the source code is developed in the open as well!
[https://github.com/3b1b/manim](https://github.com/3b1b/manim)

------
umanwizard
Possibly off-topic: why does practically any description of quaternions
include the anecdote about somebody carving something into some bridge in
Ireland?

I’ve learned about plenty of mathematical concepts while having no idea who
discovered them or under what circumstances. Why are quaternions the
exception?

~~~
nj65537
I think the story is told as a sort of cultural marker of what a Big F-ing
Deal this discovery was/is. Mathematics, collectively, struggled for a long
time to find a way to make 3-dimensional numbers into an algebra in a way that
extends the algebra of complex numbers. (The cross and dot products are
unsatisfying, because they don't have division.) The shock that this can be
done in _four_ , -- not three -- dimensions is still sort of reverberating,
and that's what I think this story marks. It's a short stand-in for the longer
story I've just summarized, and it evokes (or is meant to evoke) the mind-
shattering thrill of discovery.

I don't necessarily think the story _accomplishes_ this -- your question is
but one piece of evidence that it doesn't -- but I think for those who spend a
good amount of time with these kinds of algebra questions, it comes to take on
that role, and that's why I think it's repeated.

(Teaser -- if you want to know more about these kinds of questions, Google for
"real division algebras". There are not very many, and they way they are
organized is not, I think, something one would expect.)

~~~
xelxebar
Also, in Hamilton's time they didn't have the view of mathematics as axiom
systems that could be played with. Math was a way of finding Truth, so the
idea of making up multiplication rules at your convenience probably seemed
like an extremely non-obvious move.

The discovery of complex numbers and quaternions probably played a big part in
getting people to question what math _is_ , leading to Hilbert's program to
study Foundations etc. Hamilton's story is a nice, rare single instance we can
point to, symbolizing this discovery.

~~~
umanwizard
Fair point, but hadn’t complex numbers been around for a while by the time
quaternions were discovered?

------
adamnemecek
Dual quaternion are even whackier. They are the best formalism for reasoning
about 3D space developing over time.

Here’s a cool example [http://www.chinedufn.com/dual-quaternion-shader-
explained/](http://www.chinedufn.com/dual-quaternion-shader-explained/)

------
splittingTimes
Previous discussion

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

Those who like to have a print version:

[https://github.com/frankMilde/interesting-
reads/blob/master/...](https://github.com/frankMilde/interesting-
reads/blob/master/3d-game-engine-programming_jeremiah-van-
oosten_understanding-quaternions.pdf)

------
kuwze
I remember being introduced to quaternions recently by this post[0] which
recommended this book[1].

[0]: [https://www.haroldserrano.com/blog/best-books-to-develop-
a-g...](https://www.haroldserrano.com/blog/best-books-to-develop-a-game-
engine)

[1]: [https://www.amazon.com/Quaternions-Computer-Graphics-John-
Vi...](https://www.amazon.com/Quaternions-Computer-Graphics-John-
Vince/dp/0857297597/)

------
nraynaud
I had a question about quaternions: does anyone use them for anything else
than multiplying a rotation by a scalar?

In particular, it feels a bit like a waste of coding space to always use unit
ones.

~~~
macawfish
The remarkable thing about quaternions is that you can describe rotation
around any arbitrary axis! Try doing that with real rotation matrices and you
will bump into a major problem:

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

Because matrix multiplication is not commutative, you can't easily compose a
matrix representing rotation around an arbitrary axis from "component rotation
matrices".

With quaternions/clifford algebras, you can say "here's the vector I want to
rotate about and here's this is how much I want to rotate", and it just
magically works.

~~~
billfruit
I find that many articles explaining how to describe the orientation of a
rigid body rotated along an axis by an angle in a confusing manner.

Normally in 3d space you will have to construct quaternions for rotations
along yaw, pitch and roll, and then take their product to get the quaternion
of the orientation of the rigid body.

That is, when using quaternions to describe orientations,we are actually
describing the rotations done to bring the body from its default orientation
to its present orientation.

~~~
twtw
> Normally in 3d space you will have to construct quaternions for rotations
> along yaw, pitch and roll, and then take their product to get the quaternion
> of the orientation of the rigid body

Is this not just using Euler angles via quaternions? If I understand
correctly, tracking rotation via yaw, pitch, and roll will still run into
issues of gimbal lock because it's the same parameterization just using
quaternions.

------
edflsafoiewq
Anyone know an easy way to show that multiplication by a unit quaternion is a
unitary operator?

~~~
joppy
Unitary in what sense? Clearly multiplication by a unit quaternion preserves
the quaternion norm.

~~~
edflsafoiewq
In the sense of preserving the dot product, x.y = (ux).(uy).

~~~
joppy
Since the quaternion norm is induced via the quaternion dot product, any
transformation that preserves the norm automatically also preserves the dot
product. This is a standard result for inner product spaces.

~~~
edflsafoiewq
Ah, polarization? And for it preserving the norm you can use the conjugate.
Easy! Thanks!

------
wink
I found these videos very helpful:
[https://www.youtube.com/watch?v=SCbpxiCN0U0](https://www.youtube.com/watch?v=SCbpxiCN0U0)

------
aaaaaaaaaab
Protip: learn Geometric Algebra.

~~~
dbcurtis
Can you recommend any good references?

~~~
aaaaaaaaaab
Here’s an appetizer from Eric Lengyel in the context of game development (or
3D graphics in general):
[https://m.youtube.com/watch?v=WZApQkDBr5o](https://m.youtube.com/watch?v=WZApQkDBr5o)

And here’s the in-depth stuff:

Geometric Algebra for Computer Science:
[http://www.geometricalgebra.net](http://www.geometricalgebra.net)

------
choonway
Please use Lie Groups/Algebra instead.

~~~
formalsystem
Do you mind on elaborating on that? Any nice books or tutorials you've seen on
the subject?

~~~
choonway
Skipping the formalism you can get directly into the practical aspects in this
book.

Modern Robotics by Lynch and Park Chapters 3 and 4

pre-preprint of book / more info available here
[http://hades.mech.northwestern.edu/index.php/Modern_Robotics](http://hades.mech.northwestern.edu/index.php/Modern_Robotics)

------
bnolsen
left handed thingies. go to geometric algebra for the real meal deal.

------
paulgrant999
I have no idea why they insist on using such horrible graphs to explain a
simple idea.

Go to wiki/quaternions. scroll down to about 2/3rds of the way ;)

