Game Development Reference
In-Depth Information
the diagonal as before,
2
4 a 0
3
0
0
5
0 a 0
0
a ≡
,
0
0 a 0
0
0
0 a
and the complex quantities are mapped to the matrices
2
4 0
3
5
2
4 0
3
5
2
4 0
3
5
0
0
1
0
1
0
−1
0
0
Mapping the three
complex quantities to
4 × 4 matrices
0
0
−1
0
0
0
0
1
1
0
0
0
i ≡
, j ≡
, k ≡
.
0
1
0
0
−1
0
0
0
0
0
0
1
−1
0
0
0
0
−1
0
0
0
0
−1
0
(8.11)
We encourage you to convince yourself that these mappings do preserve all
of Hamilton's rules before moving on.
Combining the above associations, we can map an arbitrary quaternion
to a 4 × 4 matrix as
2
4 w
3
5
−z y x
Encoding quaternions as
4 × 4 matrices
z
w
−x y
w + xi + yj + zk ≡
.
(8.12)
−y x
w z
−x
−y
−z w
Once again, we notice how complex conjugation (negating x, y, and z)
corresponds to matrix transposition.
Everything we've said so far applies to quaternions of any length. Now
let's get back to rotations. We can see that the i, j, k matrices in Equa-
tion (8.11) permute and negate axes, so they bear some similarity to 90 o
rotations or reflections. Let's see if we can carry the simple ideas from 2D
forward with these matrices. Notice how the upper left 2 × 2 portion of the
k matrix is the same as the very first 2×2 matrix for i; in other words, part
of k is a 90 o rotation about z. By analogy with the 2D case, we might rea-
sonably expect the quaternion cosθ + k sinθ to represent a rotation about
the z-axis by an arbitrary angle θ. Let's multiply it by the vector [1,0,0]
and see what happens. As in the 2D case, we need to “promote” the vector
into the complex domain; what's different here is that quaternions have an
extra number. We'll map [x,y,z] to the complex number 0 + xi + yj + zk,
so the vector [1,0,0] is simply i. Expanding the multiplication, we have
(cosθ + k sinθ)i = icosθ + kisinθ,
= icosθ + j sinθ,
which corresponds to [cosθ,sinθ,0], exactly what we would expect when
rotating the x-axis about the z-axis. So far, all is good. Let's try a slightly
Search WWH ::




Custom Search