Game Development Reference
In-Depth Information
}
/ /
I n t e r p o l a t e
w =
w0 k0
+
w1 k1 ;
x
=
x0 k0
+
x1 k1 ;
y
=
y0 k0
+
y1 k1 ;
z
=
z0 k0
+
z1 k1 ;
Listing 8.3
Quaternion slerp
8.5.13 Advantages and Disadvantages of Quaternions
Quaternions offer a number of advantages over other methods of represent-
ing angular displacement:
Smooth interpolation. The interpolation provided by slerp provides
smooth interpolation between orientations. No other representation
method provides for smooth interpolation.
Fast concatenation and inversion of angular displacements. We can
concatenate a sequence of angular displacements into a single angular
displacement by using the quaternion cross product. The same oper-
ation using matrices involves more scalar operations, although which
one is actually faster on a given architectures is not so clean-cut:
single instruction multiple data (SIMD) vector operations can make
very quick work of matrix multiplication. The quaternion conjugate
provides a way to compute the opposite angular displacement very
e ciently. This can be done by transposing a rotation matrix, but is
not easy with Euler angles.
Fast conversion to and from matrix form. As we see in Section 8.7,
quaternions can be converted to and from matrix form a bit faster
than Euler angles.
Only four numbers. Since a quaternion contains four scalar values,
it is considerably more economical than a matrix, which uses nine
numbers. (However, it still is 33% larger than Euler angles.)
These advantages do come at some cost, however. Quaternions suffer
from a few of the problems that affect matrices, only to a lesser degree:
Slightly bigger than Euler angles. That one additional number may
not seem like much, but an extra 33% can make a difference when
large amounts of angular displacements are needed, for example, when
storing animation data. And the values inside a quaternion are not
“evenly spaced” along the [−1,+1] interval; the component values do
not interpolate smoothly, even if the orientation does. This makes
 
Search WWH ::




Custom Search