Repository files navigation CS3242 Lecture 2: Quaternions Cheat Sheet
Rotation Representations:
Matrix (3x3, 9 elements)
Euler Angles (3 angles, suffers from gimbal lock)
Axis-Angle Representation
Quaternions (4 elements, no gimbal lock, efficient)
2. Complex Numbers and Quaternions
Complex number: ( p = x + iy ) (2D rotations)
Quaternions extend complex numbers to 3D:
( q = w + ix + jy + kz = (w, x, y, z) )
One real component (( w )), three imaginary (( x, y, z ))
Quaternion multiplication follows these rules:
( i^2 = j^2 = k^2 = -1 )
( ij = k, ji = -k )
( jk = i, kj = -i )
( ki = j, ik = -j )
Unit quaternion: ( ||q|| = \sqrt{w^2 + x^2 + y^2 + z^2} = 1 )
Used for representing 3D rotations.
5. Quaternion as Rotations
A rotation by angle ( \theta ) around unit axis ( \mathbf{a} = (a_x, a_y, a_z) ) is:
[
q = \cos(\theta/2) + (a_x i + a_y j + a_z k) \sin(\theta/2)
]
Applying quaternion rotation:
[
p' = q p q^*
]
where ( q^* = (w, -x, -y, -z) ) is the conjugate.
6. Converting Quaternion to Rotation Matrix
The corresponding rotation matrix for a quaternion ( q = (w, x, y, z) ) is:
[
R =
\begin{bmatrix}
1 - 2(y^2 + z^2) & 2(xy - wz) & 2(xz + wy) \
2(xy + wz) & 1 - 2(x^2 + z^2) & 2(yz - wx) \
2(xz - wy) & 2(yz + wx) & 1 - 2(x^2 + y^2)
\end{bmatrix}
]
7. Quaternion Interpolation
7.1 Linear Interpolation (LERP)
Simple interpolation between two quaternions:
[
LERP(q_1, q_2, t) = (1 - t)q_1 + t q_2
]
Not ideal for rotations, as it doesn't maintain unit length.
7.2 Spherical Linear Interpolation (SLERP)
Interpolates along the shortest path on the quaternion sphere:
[
SLERP(q_1, q_2, t) = \frac{\sin((1 - t)\theta)}{\sin\theta} q_1 + \frac{\sin(t\theta)}{\sin\theta} q_2
]
Ensures smooth rotation.
8. Example: Rotating a Point Using Quaternions
Define quaternion ( q ) for rotation.
Convert point ( p = (0, x, y, z) ) into a pure quaternion.
Compute rotated point: ( p' = q p q^* ).
Quaternions are a compact, efficient way to represent 3D rotations.
Avoids gimbal lock, provides smooth interpolation.
Essential for 3D animation, robotics, and physics simulations.
You can’t perform that action at this time.