Game Development Reference
In-Depth Information
Quaternion multiplication can be used to concatenate multiple rotations,
just like matrix multiplication.
We say “just like matrix multiplication,” but in fact there is a slightly
irritating difference. With matrix multiplication, our preference to use row
vectors puts the vectors on the left, resulting in the nice property that
concatenated rotations read left-to-right in the order of transformation.
With quaternions, we don't have this flexibility: concatenation of multiple
rotations will always read “inside out” from right to left. 12
8.5.8 Quaternion “Difference”
Using the quaternion multiplication and inverse, we can compute the dif-
ference between two quaternions, with “difference” meaning the angular
displacement from one orientation to another. In other words, given orien-
tations a and b , we can compute the angular displacement d that rotates
from a to b . This can be expressed compactly as
da = b .
(Remember that quaternion multiplication performs the rotations from
right-to-left.)
Let's solve for d . If the variables in the equation represented scalars,
we could simply divide by a . However, we can't divide quaternions; we
can only multiply them. Perhaps multiplication by the inverse will achieve
the desired effect? Multiplying both sides by a
−1 on the right (we have
to be careful since quaternion multiplication is not commutative) gives us
−1 = ba
−1 ,
( da ) a
The quaternion
“difference”
−1 ) = ba
−1 ,
d ( aa
−1 ,
d
1 0
= ba
−1 .
d = ba
Now we have a way to generate a quaternion that represents the angular
displacement from one orientation to another. We use this in Section 8.5.12,
when we explore slerp.
12 Actually, you do have some flexibility if you're willing to buck the system. Some
crazy authors [16] have gone so far as to provide an alternative definition of the quater-
nion product with the operands reversed. This can lead to code that is easier to un-
derstand, and this option might be worth considering in your own code. However, we'll
stick with the standard in this topic.
 
Search WWH ::




Custom Search