<aside>

[[ NEW ]] QUATERNIONS INTRODUCTION ADDED PART 5 [[ NEW ]] 🟡

Must read. This will give you the mental model to follow up.

</aside>

What are those 4 numbers anyways?

<aside>

Think of a quaternion as a number system with four components:

$$ q = (x,y,z,w) $$

</aside>

Quaternions in Houdini & Computer Graphics

<aside>

In Houdini and computer graphics, unit quaternions are commonly used to represent 3D rotations / orientations.

</aside>

What does "unit" mean?

<aside>

A unit quaternion is a quaternion whose magnitude is 1.

$$ |q| = \sqrt{x^2+y^2+z^2+w^2}=1 $$

</aside>

"Unit" doesn't mean the quaternion's value is 1.

See: HOS — Introduction to Vectors

Why should I care?

Because unit quaternions are what we use to represent pure 3D rotations.

<aside>

Unit quaternion → valid rotation representation

</aside>

A quaternion can have any magnitude.

But when we use a quaternion to represent a rotation, we want its magnitude to be 1.

This keeps the quaternion representing rotation / orientation, without introducing an unwanted scale factor.

(This is analogous to a normalized 3D vector.)

For a vector:

$$ v=(x,y,z) $$

Calculate its magnitude:

$$ |v|=\sqrt{x^2+y^2+z^2} $$

For a quaternion:

$$ q=(x,y,z,w) $$

Calculate its magnitude:

$$ |q|=\sqrt{x^2+y^2+z^2+w^2} $$

The result is 1, while pointing in the same direction

$$ \sqrt{x^2+y^2+z^2+w^2}=1 $$

A quaternion's magnitude is calculated the same way as a vector's.


How it is Constructed? Stay strong.

<aside>

Axis + Angle and the quaternion are two different representations of the same rotation. The four numbers aren't four separate pieces of information. Together, they encode the same rotation described by the Axis + Angle.

</aside>

So what it is inside those 4 numbers?

Axis = (x, y, z)
Angle = 90

        ↓

qx = x · sin(90/2)
qy = y · sin(90/2)
qz = z · sin(90/2)
qw = cos(90/2)

$$ so $$

Axis = (0, 1, 0)
Angle = 90

        ↓

qx = x · sin(45°) = 0
qy = y · sin(45°) = 0.707
qz = z · sin(45°) = 0
qw = cos(45°)     = 0.707

        ↓

Quaternion = (0, 0.707, 0, 0.707)

<aside>

$$ \text{Axis + Angle} \longrightarrow \text{Quaternion} $$

$$ (0,1,0) + 90^\circ \longrightarrow (0,0.707,0.707,0) $$

</aside>

Think of sin() and cos() as calculator functions that take an angle and return a number.

$$ sin(45^circ) = 0.7071 $$

$$ cos(45^circ) = 0.7071 $$

In Plain English: sin(90/2) = sine of half the angle. cos(90/2) = cos of half the angle.

Why Half Angle? The Quaternion sandwich

Because the quaternion doesn't rotate a vector by using the angle directly. Half-angle it**'s there because the rotation operation uses the quaternion twice, no need to know more for now.**

<aside>

Still want to know more? Google this

$$ (qvq^{-1}) $$

</aside>