Body Trails - A Visual Aesthetic
Colored visual effect that trails delayed
I hate quaternions.
me

I hate quaternions so much.
me

With every fiber of my being.
me

Seriously.
me
In the world of 3D game development, quaternions are dark magic. They are mathematically dense, impossible to visualize intuitively, and yet, you have to use them.
Think of quaternions as a way to represent an orientation or a rotation in 3D space using four numbers: $(x, y, z, w)$. While they look intimidating, they solve the messy problems that traditional methods like Euler angles (pitch, yaw, roll) create.
In skeletal animation, a “skeleton” is a hierarchy of bones. If you rotate a shoulder, the elbow, wrist, and fingers must follow. This requires constant, smooth calculations.
In my case, I had to program ragdolls; in my 3D zombies game, zombies had to fall over when they died, because you know, realism. But, this was seemingly impossible to program. Every YouTube tutorial got it so wrong (maybe I’m the common denominator). I was hopeless.
I actually had to learn how to program… quaternions.

Euler angles represent rotation as three successive turns. If two of those axes align (e.g., you rotate the pitch $90^\circ$ degrees), you lose a degree of freedom. Your bone suddenly “snaps” or refuses to move in a certain direction. Quaternions represent rotation as a single state in 4D space, making Gimbal lock mathematically impossible.

yall ever slerp your quaternions?
someone
When a character moves from a “rest” pose to a “punch” pose, the engine has to calculate all the frames in between.
While a $3 \times 3$ rotation matrix uses 9 numbers, a quaternion uses only 4. When you’re calculating the transformations for a character model with 100+ bones at 60 frames per second, that memory and computational savings add up quickly.
You don’t need to be a mathematician to use them (most engines like Unity or Unreal handle the heavy lifting), but it helps to know what’s under the hood. A quaternion is defined as:
\[q = w + xi + yj + zk\]Where:
If you want to rotate a bone by an angle $\theta$ around a unit axis vector $(u_x, u_y, u_z)$, the quaternion is:
\[q = \left[ \cos\left(\frac{\theta}{2}\right), u_x \sin\left(\frac{\theta}{2}\right), u_y \sin\left(\frac{\theta}{2}\right), u_z \sin\left(\frac{\theta}{2}\right) \right]\]| Feature | Euler Angles (Pitch/Yaw/Roll) | Quaternions |
|---|---|---|
| Human Readable | Yes (e.g., “Rotate 90 degrees”) | No (e.g., “0.707, 0, 0.707, 0”) |
| Gimbal Lock | Yes | No |
| Interpolation | Jerky / Non-linear | Smooth (SLERP) |
| Storage | 3 Floats | 4 Floats |
| Best Use Case | Editor UI / Simple UI input | Skeletal Physics / Core Engine Math |
Where I applied quaternions:
Here’s a photo gallery of the hell I went through with quaternions!
