Game Development Reference
In-Depth Information
Mathematically, the angular difference between two quaternions is ac-
tually more similar to a division than a true difference (subtraction).
8.5.9 Quaternion Dot Product
The dot product operation is defined for quaternions. The notation and
definition for this operation is very similar to the vector dot product:
w 1 v 1
w 2 v 2
q 1 q 2 =
Quaternion dot product
= w 1 w 2 + v 1 v 2
=
x 1 y 1 z 1
x 2 y 2 z 2
w 1
w 2
= w 1 w 2 + x 1 x 2 + y 1 y 2 + z 1 z 2 .
Like the vector dot product, the result is a scalar. For unit quaternions a
and b , −1 ≤ a b ≤ 1.
The dot product is perhaps not one of the most frequently used quater-
nion operators, at least in video game programming, but it does have an
interesting geometric interpretation. In Section 8.5.8, we considered the
difference quaternion d = ba
, which describes the angular displacement
from orientation a to orientation b . (We assume unit quaternions and re-
place the quaternion inverse with the conjugate.) If we expand the product
and examine the contents of d , we find that the w component is equal to
the dot product a b !
What does this mean geometrically? Remember Euler's rotation the-
orem: we can rotate from the orientation a into the orientation b via a
single rotation about a carefully chosen axis. This uniquely determined
(up to a reversal of sign) axis and angle are precisely the ones encoded in
d . Remembering the relationship between the w component and the rota-
tion angle θ, we see that a b = cos(θ/2), where θ is the amount of rotation
needed to go from the orientation a to the orientation b .
In summary, the quaternion dot product has an interpretation similar to
the vector dot product. The larger the absolute value of the quaternion dot
product a b , the more “similar” are the angular displacements represented
by a and b . While the vector dot product gives the cosine of the angle
between vectors, the quaternion dot product gives the cosine of half of the
angle needed to rotate one quaternion into the other. For the purpose of
measuring similarity, usually we are interested only in the absolute value
of a
b , since a
b = −( a
b ), even though b and −
b represent the same
angular displacement.
Although direct use of the dot product is infrequent in most video game
code, the dot product is the first step in the calculation of the slerp function,
which we discuss in Section 8.5.12.
Search WWH ::




Custom Search