Have you been hearing the term âQuaternion Rotationsâ in Blender and wondered what they are -- or even how to control them?
What this article covers
So...what are quaternion rotations?
Quaternions are 3D rotations performed by the multiplication of quaternions.
Got it? Yeah, probably not...
Before explaining how these rotations work, Â we'll need to define a few terms first.
Before we begin...
1) In computers, everything is represented by numbers.
Numbers make up everything we do on computers (including Blender). Whether it is a character, an operation, the position of a pixel on your screen, a color... or even a number. Blender will see all operations and input as numbers.
2) Any point in 3d space has three coordinates
A single point P has coordinates x, y and z. For example, (3.0, 0.73, 2.5). But these coordinates can also represent a 3-dimensional vector.
A number in the form of a âtripleâ (a, b, c) can represent a simple point, but it could also be another 'type'.
A 'type' refers to a point, but also a color, or a vector.Â
One type can even change into another, which is what we call 'type-switching'.Â
3) A triple can represent a vector type
You may remember vectors from high school maths: a vector is like an arrow, with a direction and a length, but not a fixed position.Â
In our example, vector (3.0, 0.73, 2.5) is an arrow going from the origin (0, 0, 0) to point (3.0, 0.73, 2.5).Â
It can be placed anywhere in 3D space, it is still considered the same vector, just with a different triple.
You can rotate or scale a vector and its coordinates will change accordingly.
Internally, Blender will see all these numbers as âtriplesâ. Â
4) Blender uses triples to determine various operations
Knowing this, we can do some cool things like use a Vector output to drive the color of a shader.
And because everything is a number itâs also possible to do completely ridiculous and meaningless things: like determining the length of color. Â What!? Â A colour can have a length? Â Well a color to Blender is just a number and so yes, you can find the length of that number.
 In this example I am taking the cross product of a point in space and a Noise Texture, and plugging the result into an emission shader. Did I mention you can do completely ridiculous things with numbers?
5) Quaternions = Hamilton numbers
In the rest of this article, I am going to do something outrageous and call quaternions âHamilton numbersâ. Firstly, I think this sounds more friendly, less intimidating. And secondly, this way you are less likely to forget that a quaternion is a number.Â
Understanding Complex Numbers (in 2D)
Hamilton numbers are the best way to rotate in 3d space - and we will get to them shortly, but for simplicity, first, let's look at 2D.
(Watch out: extreme âtype-switchingâ ahead!)
Letâs say we have a 2-dimensional plane, called 'real plane', with a point that we want to rotate around the Origin.
(If we can do that, we can rotate as many points as we like around any point on the plane.)
Now, we'll create a (linked) âcopyâ of this plane and place it perpendicular to our real plane. The copy is called a 'complex plane' (for historical reasons, not because of its complexity! We might as well call it the relax plane...):
Everything that happens in the real plane also happens in the complex copy -- and vice versa.
ďżź
For every point (a, b) on our real plane, there is a point on the complex plane.Â
This point represents a complex number (a+bi). The i portion of this is called an âimaginary numberâ, where  i² = -1.
Quick recap: Now we've introduced complex numbers (points on our complex plane) and an imaginary number i.
Now, multiplying two points doesnât make much sense, but we can easily multiply two numbers (even when they are âcomplexâ).Â
Example 01 with complex numbers in 2d
For a point P(a, b) in our real plane, there is a corresponding point P(a+bi) in the complex plane.
If we multiply this point by i [this is the complex number (0+1i)], we get:Â
Now comes the beautiful part: if we look at this graphically, we can see that we just rotated the vector (a, b) by 90° (around the Origin):
Thereâs one thing to note about this example.
We multiplied our vector by i, which has a length of 1. Â That's because it is a vector that moves exactly 1 unit in a given direction.Â
If we would have multiplied by 2i, we still would have rotated 90°, but also scaled vector P by a factor 2.
There's another way of seeing this.Â
The same operation would be done if we multiplied two vectors by adding their angles and multiplying their lengths.Â
So we will make it a convention to only multiply by vectors of length 1, that is: by numbers, whose corresponding points lie on the unit circle. When we add the angles and multiply the length by 1, we will only get the rotation, without any scaling.
Example 02 with complex numbers in 2d
This works for any angle; we take the unit vector in the complex plane that makes the desired angle with the positive X-axis and multiply the corresponding number by the number belonging to the point we want to rotate. Put the result back into the real plane and Bobâs your uncle.
If we call the angle of rotation , we can also write point C as: (cos, sin) and the number as: (cos+isin). This will become especially useful in 3D.Â
If a number lies on the unit circle, meaning it corresponds to  a  vector of length 1, we say the number has a Norm 1. (As numbers do not have a length. This is the equivalent of length for vectors and distance (to origin) for points.)
Example 03 with complex numbers in 2d
Here is an important term:Â
if we have a complex number then we callits complex conjugate.
(Here I use the notation C'Â to indicate the conjugate of C, but there are other notations that you may encounter...)
When we multiply a complex number P by some complex number C of Norm 1, we rotate by a certain angle θ.
If we after that multiply again, but this time by the conjugate of C, we rotate by an angle of (360°-θ) and thereby return to the original place of P.
As a special case: if P is an imaginary number, meaning its real part is 0, for instance: then is also an imaginary number for any complex number C. Although this sounds trivial here, it will be extremely important when dealing with 3D rotations!Â
Multiplications of this form are called sandwich multiplications, for (I hope) obvious reasons.
OK this is how it works in 2d, and you can stop reading here, knowing that a similar thing occurs in 3d space, though it gets way more complex. If you want to dive into that, keep on reading, but put on your safety helmet first!
Understanding rotations in 3d
Still reading? Â Safety helmet on? Good. Letâs see if we can also rotate in 3D, by multiplying special numbers.
Spoiler alert: we can.
The first idea, to use special numbers of the form (a+bi+cj) doesnât work. (Mathematicians have been trying this for quite some time without successâŚ)
The Irish mathematician Sir William Rowan Hamilton (whilst walking along the Royal canal in Dublin, not at all paying attention to what his wife was telling, about how her friend had been wearing this outrageously colored dress at last nightâs soiree) discovered that we need special numbers of the formwhere These are what I shall refer to as Hamilton numbers. (Remember that I use that as a sort of euphemism for quaternions; they are not actually called that.)
Now, imagine a (linked) âcopyâ of our beloved 3D space. In your mind, place this copy perpendicular to our 3D space (donât worry if you canât do this. Maybe you can imagine two paralel 3 dimensional worlds...). Â We shall call this the imaginary (3 dimensional) world. Every point in our real world has a corresponding point in this imaginary world. And everything that happens in the imaginary world, happens in the real world and vice versa. Â Just like in the Netflix series Stranger Things!
Â
Hereâs a sloppy version of how quaternion rotations work...
Under the hood, Blender takes the vector of rotation, divides it by its length and puts it in the imaginary world, along with the object that needs to be rotated, then rotates the object twice by a multiplication sandwich of Hamilton numbers; the first part of the sandwich creates a Hamilton number with a (usually) non-zero real part, meaning we now have one foot in the real world, while our other three limbs are still in the imaginary world. The second part of the sandwich multiplication makes the real component zero again, so that we are completely back in the imaginary world. Then, Blender puts the rotated object back into the real world (and whoâs your uncle?).
By multiplying twice, we also rotated twice (in the same direction!), that is why we need each of those rotations to be half the angle we want the 3D rotation to be.Â
And although I donât recommend ever trying to visualize what is happening in more than 3 dimensions, hereâs an exclusive âbehind the scenesâ of what happens when we project the 4 dimensional Hamilton Space onto our 3 dimensional world and make a quaternion rotation of 90° around the (1, 1, 1) vector. Be aware that this is like a 3 dimensional âshadowâ of what is happening in 4D; this is not what it would look like in 4D.
In Blender, if we set the rotation mode to quaternion we get the 4 fields: W, X, Y and Z. Important to notice here is, that the angle of rotation is contributing to all four; to be precise, if the angle of rotation is θ, and the unit vector around which we want to rotate is (a, b, c), then:
[As we have set  and
Just to be clear: that rotation vector is placed at the objectâs origin. If the object is rotated around some other line, then that is done by rotation around the objects origin AND a translation.
You don't actually have to fill in those fields by hand, but it is good to know what is happening.Â
Here is some of the math. You also don't need to do this manually, but I think it is a good idea to at least have seen it once. However, if you are feeling brave you can also try this at home! (It looks much more complicated than it actually is)
Getting Stuck into the Numbers: Quartnenions in 3d
As in the case of the complex numbers (...which completely sounds like a lost Sherlock Holmes novel) if we have a Hamilton number then its conjugate isÂ
Furthermore, we will need the following formulas for multiplication;Â
With these rules multiplying any two Hamilton numbers is now super easy (apart from the many terms you need to keep track of...).
There are a few things I would like to point out here:Â
Let's say we want to multiply above-mentioned Hamilton number h with another Hamilton number p. That is hp, not ph.  The order matters here as mentioned above.
So letâs say
Like I said before, this results in a (usually) non-zero real component, namely:Â
The imaginary components after this multiplication hp are:Â
Now we are going to multiply this by the conjugate of
(So, the total multiplication is:Â )
The resulting real part is now:Â
 You can see how this works and maybe you can 'feel' how the property etc. accounts for the fact that âleft-multiplyingâ by h results in the same rotation as âright- multiplyingâ by h'.Â
And if you are not convinced, you can carry out the complete sandwich multiplication yourself.
That is why we use half the angle in the rotation. Because we have to multiply twice!
Before you Go: Take-Home Challenge
Your head is probably spinning by now, but I am not completely finished with you just yet; hereâs a little challenge:
Open Blender, delete the default Cube, add a Monkey and switch the rotation mode to Quaternion (I know, not much of a challenge yet for most of you, but waitâŚ)
Fill in the W, X, Y, Z fields, so, that Suzanne rotates 180° around the axis that goes through (0, 0, 0) and (3, 4, 5).
Maybe try other angles and axes and, if you feel confident, find the axis and angle when:
And you might want to confirm that: (or very close to 1, due to rounding errors).
Thatâs all folks! Thatâs all there is to it. Câest simple comme bonjour. (itâs as simple as âhelloâ)
I hope you more or less âgetâ quaternion rotations by now and I would like to end with these wise words: the more you think about it, the more sense it will make.Â
spikeyxxx đ đ đ huge props for putting this together, I understand just enough to be thoroughly impressed...and then cower in the corner crying.
coyohti yeah, it's math, sorry, but, having seen many people, trying to explain it without using algebra and obviously not knowing what they were talking about, made me write this. Read it again when you feel up to it and it will become less scary with time :)
I felt like I was doing pretty good at the start but ended up huddled under a blanket clutching my binky about halfway through.
Which is further than I've reached before trying to understand fancy math so good work! :D
blanchsb thanks, Wayne and I have been working a long time on this! Hope you like it :)
AT LONG LAST! Spikey gives us the nitty-gritty behind the quaternions. This has been a long time coming since his promise to explain it in the forums. And here it is in all of it's glory. Well done spikeyxxx and thank you for all of the hard fought hours put into making this explanation happen. I will go through this tonight in detail but wanted to post my thanks in advance.
dostovel thanks a lot. I hope I still left some of your brain intact :)
duerer thanks! I hope this will clear things up a bit for you. Feel free to ask any questions when something is still unclear.
aartifact Thank you.
Don't worry too much about not understanding the math: the two main points to take away from this are: 1. a quaternion is just a number.
2. a quaternion rotation is actually a multiplication.
Can't say I understood much of the math. But I CAN say fantastic Job, spikeyxxx
After confronting my fears and reading all the math and standing brave amidst all the numbers and melting my brain a little, I can say job well done Spikey.