Rotations
Problem
- Animation by repeated rotation are hard to manage: how to represent, reason about, and interpolate between?
- Basic issue: too many degrees of freedom to easily represent
- Axis-Angle
- represents rotation as a line of points that don't change (axis) and amount of rotation (angle)
- good for single rotations
- hard to reason about when combined because "axis" changes
- bad because, after several matrix multiplications, may no longer be orthogonal due to floating point inaccuracies
(difficult to renormalize)
- Euler angles
- standard terminology: yaw, pitch, roll
- easy to combine and understand
- bad because order matters, so must decide prescribed order
- bad because leads to gimbal lock, cannot specify certain rotations
- From GameDev.net's rotations FAQ:
Because the final rotation matrix depends on the order of
multiplication, it is sometimes the case that the rotation in one
axis will be mapped onto another rotation axis. Even worse, it may
become impossible to rotate an object in a desired axis. This is
called Gimbal lock. For example, assume that an object is being
rotated in the order Z,Y,X and that the rotation in the Y-axis is 90
degrees. In this case, rotation in the Z-axis is performed first and
therefore correctly. The Y-axis is also rotated correctly. However,
after rotation in the Y axis, the X-axis is rotated onto the Z-axis.
Thus, any rotation in the X-axis actually rotates the object in the
Z-axis. Even worse, it becomes impossible to rotate the object in the X-axis.
Quaternions
- History
- Invented in 1843 by Sir William Hamilton (after he had done his "good work")
- Extends complex numbers from 2D to 3D
- Reinterpreted for computer graphics in 1985 by Ken Shoemake
- Provides a continuous space to represent rotations, thus avoiding problems inherent in other rotation models
- Use in other sciences
- The invention of the calculus of quaternions is a step towards the knowledge of quantities related to space which can only be compared for its importance with the invention of triple coordinates by Descartes. The ideas of this calculus, as distinguished from its operations and symbols, are fitted to be of the greatest use in all parts of science. — James Clerk Maxwell, 1869
- Oliver Heaviside in England and Josiah Willard Gibbs at Yale University felt that quaternion methods were too cumbersome, often requiring the scalar or vector part of a result to be extracted. Thus, about forty years after the quaternion product, the dot product and cross product were introduced — to heated opposition. Pivotal to (eventual) acceptance was the efficiency of the new approach, allowing Heaviside to reduce the equations of electromagnetism from Maxwell's original 20 to the four commonly seen today. — Paul Nahin
- Elegance and beauty
- Of possible quadruple algebras the one that had seemed to him by far the most beautiful and remarkable was practically identical with quaternions, and that he thought it most interesting that a calculus which so strongly appealed to the human mind by its intrinsic beauty and symmetry should prove to be especially adapted to the study of natural phenomena. The mind of man and that of Nature’s God must work in the same channels. — written about Benjamin Peirce, 1925
- Other uses in graphics
- In fact, Rotations, Reflections, and Perspective Projections in 3–Dimensions can all be Modeled by Simple Rotations in 4–Dimensions — Ron Goldman, Rice University
- Implementation provided in all languages, so do not necessarily need to understand the math
- Often conversion from other rotation models provided
- So, can typically be swapped in for standard OpenGL rotations easily
- Now viewed as the standard way to do rotations in games, VR, etc.
Interpolation
- Where Quaternions really shine: provides standard interpolation from one arbitrary rotation to another
- Interpolation: standard practice for key frame animation
- Linear Interpolation fails to generate another rotation matrix (not necessarily orthogonal matrices):
Lerp(R,R,t) = (1−t)R + tR
- Spherical Linear Interpolation between two unit quaternions always generates a unit quaternion
Slerp(q1,q2,t) = sin(1−t)φ*q1 + sintφ*q2
- Interpolation path: shortest, reproducible path between rotations
- Not uniquely defined because no standard order and angles are not independent
- Two standard paths (around the sphere): take the shortest (positive) path
References