News for hackers. Stuff that matters.
Re:How Quaternions encode rotations: derivation and sample code by uryga on Wednesday September 07, 2016 @07:00AM (#12442246)
===== EDIT: this is mostly wrong - see jblow's reply. Sorry for misleading you into thinking I know what I'm talking about :D =====

I think of it like this: a complex number represents a rotation in a plane. You need two "coordinates" to do that. 2d has one plane, but 3d has two planes - think about how an anti-air cannon rotates left-right and up-down. So, if we've got two rotations to represent, you must need two complex numbers - that's four "coordinates", or one quaternion.

Re:How Quaternions encode rotations: derivation and sample code by lloeki on Wednesday September 07, 2016 @10:54AM (#12443886)
Unfortunately you got it wrong, and your AAA example shows it very well.

Just as in 2d with a complex, in 3d you can encode rotations with a 3d vector. The problem is that to reach any point from any other arbitrary point you can't use a single rotation, but a combination of two, sometimes three. Think about how your AAA gun operates or FPS viewpoint controls. Thus you start to use rotations along the three axes of a base which gives you a typical rotation matrix.

As soon as you start to compose rotations along axes you introduce a terrible phenomenon known as gimbal locking, where discontinuities appear especially near north and south poles.

And so, just as a 2D rotation in a plane can be represented by a vector orthogonal to that plane (i.e in a space outside the plane), the gimbal lock and all artifacts that are cumbersome when constraining ourselves in 3D can be dealt with by going up a dimension... Hence quaternions which encode+ a rotation by putting an arbitrary but well chosen axis and an amplitude in a space grown othrogonally to our 3D space.

+ Or isomorohically so

Re:How Quaternions encode rotations: derivation and sample code by blt on Wednesday September 07, 2016 @12:58PM (#12445022)
Your analogy is incomplete because you forget rotating the cannon about its barrel.
Re:How Quaternions encode rotations: derivation and sample code by chombier on Wednesday September 07, 2016 @07:05AM (#12442266)
> but 3d has two planes

Why not 3 planes?

Re:How Quaternions encode rotations: derivation and sample code by uryga on Wednesday September 07, 2016 @07:41AM (#12442463)
Okay, my wording wasn't the best here. 3d doesn't "have" 2 planes. But, for some reason, you can look in any direction in 3d by turning in two planes. Test it yourself: turning your head left-right is rotation in one plane, turning it up-down is rotation in the other plane. here's my shot at illustrating this: https://goo.gl/photos/Cxt7KPbos5o2QnkD9

to be completely honest, I'm not sure if this intuition is correct. But it seems to make sense

Re:How Quaternions encode rotations: derivation and sample code by petters on Wednesday September 07, 2016 @08:26AM (#12442759)
I don't think that's correct. You can also rotate around the direction you are looking.

Rotations in 2D are one-dimensional. Complex numbers are two-dimensional but we fix one degree of freedom by fixing the length.

Rotations in 3D are there-dimensional. Quaternions are four-dimensional but we fix the length again.

Re:How Quaternions encode rotations: derivation and sample code by jblow on Wednesday September 07, 2016 @08:00AM (#12442569)
It's correct that you can look in any direction with only two planes, but that's not enough; you need to be able to control your orientation around that final axis. You need 3 planes for that (3 "rotational degrees of freedom"). The idea that a quaternion is somehow two complex numbers is wrong.
Re:How Quaternions encode rotations: derivation and sample code by uryga on Wednesday September 07, 2016 @08:32AM (#12442794)
Thanks. I did some research and found out that, indeed, my vague understanding of quaternions was wrong. I remember skimming the Wikipedia article and seeing this: https://en.m.wikipedia.org/wiki/Quaternion#Quaternions_as_pa...

I then assumed that my idea with two rotations is how quaternions work. Here's to actually reading about a concept before I start explaining it next time...

Re:How Quaternions encode rotations: derivation and sample code by chombier on Wednesday September 07, 2016 @08:36AM (#12442818)
I think you can do that using two rotation axis only (cf. proper Euler angles).

And quaternions are made of two complex numbers.

edit: typo.

Re:How Quaternions encode rotations: derivation and sample code by Kristine1975 on Wednesday September 07, 2016 @09:32AM (#12443204)
>And quaternions are made of two complex numbers.

I don't pretend to grok quaternions (I only use them), but I'm fairly sure a quaternion consists of three imaginary numbers plus a real number.

Re:How Quaternions encode rotations: derivation and sample code by chombier on Wednesday September 07, 2016 @10:16AM (#12443543)
Sure, but the way they play together can also be expressed by the means of two complex numbers (which makes 4 real numbers in total).
Re:How Quaternions encode rotations: derivation and sample code by jblow on Saturday September 10, 2016 @02:28PM (#12470342)
This is not true. You can't factor a quaternion into two complex numbers. Please don't spread misinformation.