Game Development Reference
In-Depth Information
more general vector [1,0,1], which is represented in the complex domain as
i + k:
(cosθ + k sinθ)(i + k) = icosθ + k cosθ + kisinθ + k 2 sinθ
= icosθ + j sinθ + k cosθ − sinθ.
(8.13)
This result does not correspond to a vector at all, since it has a nonzero
value for w. The rotation in the xy-plane worked as expected, but un-
fortunately, the z component did not come out right. There is unwanted
rotation in the zw-hyperplane. This is made perfectly clear by looking at
how (cosθ + k sinθ) is represented as a 4 × 4 matrix:
2
4 cosθ
3
5
− sinθ
0
0
sinθ cosθ
0
0
cosθ + k sinθ ≡
.
0
0
cosθ sinθ
0
0
− sinθ cosθ
The upper-left 2 × 2 rotation matrix is the one we want; the lower-right
2 × 2 rotation matrix is not wanted.
Now we are left wondering if maybe we did something wrong. Perhaps
there are other 4 × 4 roots of −1 we could use for i, j, and k—alternative
ways that we could embed the quaternion set within the set of 4×4 matrices.
In fact, there are other alternatives, and this is a hint that something is
a bit different from the 2D case. Unfortunately, all of these alternatives
exhibit variations of what is essentially the same behavior we are seeing
here. Perhaps, instead, our problem is that we did the multiplication in the
wrong order. (After all, multiplication of i, j, and k is not commutative.)
Let's try putting the vector on the left and the rotation quaternion on the
right:
(i + k)(cosθ + k sinθ) = icosθ + ik sinθ + k cosθ + k 2 sinθ
= icosθ − j sinθ + k cosθ − sinθ.
Comparing this to Equation (8.13), when the operands were in the opposite
order, we see that the only difference is the sign of the y-coordinate. At first
glance, it looks like this is actually worse. The rotation in the xz-plane that
we want got inverted; now we have a rotation by −θ. Meanwhile, the extra
rotation we didn't want is exactly the same as before. But perhaps you can
already see the solution. If we use the opposite rotation, which corresponds
to using the conjugate of the quaternion, we fix both problems:
(i + k)(cosθ − k sinθ) = icosθ + j sinθ − k cosθ + sinθ.
So, multiplying on the left by (cosθ + k sinθ) produced the rotation we
wanted, plus some extra rotation we didn't want, and multiplication on
Search WWH ::




Custom Search