Lecture 12: Rotation Representations
First, let’s just generally talk about rotations.
- Euler angles
- Rotation matrix for each axis, apply
- Order can be anything
- Rotation matrix
- The columns form the basis vectors
- Orthonomal basis vectors
Rotation Interpolation
The familiar methods of rotation representation will not work! What are those methods?
- Euler angles
- Rotation matrix
Euler angles absolutely won’t work and will look bad (not constant angular velocity). Euler angles are also also susceptible to gimbal lock. Rotation matrices have basically the same problem with regard to interpolation. It can be solved but is math heavy.
However, there is a rotational representation that has a simple way to interpolate! It’s called quaternions.
Quaternions - Simple Mode
Quaternions can be used to represent a rotation. And they’re in glm!
You can make a quaternion from Euler angles:
glm::quat q = glm::quat(euler);
And from a rotation matrix:
glm::quat q = glm::quat(matrix);
And you can easily interpolated between two quaternions:
glm::quat q = glm::slerp(q0, q1, 0.5f);
And finally, you can get a rotation matrix back from the quaternion:
glm::mat4 m = glm::mat4_cast(q);
Quaternions - Math Mode
Complex Numbers
Recall, complex numbers:
is a real number.
is an imaginary number.
It has some interesting rules:
So we can multiply two complex numbers following the rules of algebra:
We can also write this:
Alright, what else can we do with complex numbers? We can plot them in 2D.
Doing so shows us a few interesting aspects of complex numbers:
- If we multiply by , the number rotates around 90 degrees.
- If we multiply by , the number rotates around 180 degrees.
What if we multiply by any other unit-length complex number?
But wait! This looks like…
Because it is.
What about 3D?
This is rotation around a single axis, and we need two numbers to do it - a real and imaginary part.
We also use unit-length complex numbers, not just all of them.
To represent a 3D rotation, with is around three axis, we need four numbers to do it - a real and three imaginary parts.
Euler’s rotation theorem tells us that we can represent any arbitrary rotation in 3D as a rotation around a single axis by a given rotation .
So we need exactly four numbers to describe an arbitrary rotation. This makes sense! (I hope).
Quaternions
Okay so what is this set of four numbers, three of which are imaginary?
and and
and and
This forms an extended version of the complex numbers:
We can write the coordinates this way:
Or as a scalar and vector pair:
How can we represent a rotation with this?