Game Development Reference
In-Depth Information
Figure 14.12
Our teapot two-thirds of the way through a rotation
using quaternions.
If you think this seems like a whole lot of work with little gain, let
'
s look at the inter-
polation problem. Let
s assume that I want the teapot to turn so that the spout is
pointing down the Z-axis, which would mean a rotation about the Y-axis with an
angle of
'
s also assume that I want to know what the transformation
matrix is at two-thirds of the way through the turn, as shown in Figure 14.12.
Here ' s the code:
- π
/2 degrees. Let
'
D3DXQUATERNION start, middle, end;
D3DXQuaternionIdentity(&start);
D3DXQuaternionIdentity(&middle);
D3DXQuaternionIdentity(&end);
D3DXVECTOR3 axis(0,1,0);
float angle =
D3DX_PI / 2.0;
D3DXQuaternionRotationAxis(&start, &axis, 0);
D3DXQuaternionRotationAxis(&end, &axis, angle);
Search WWH ::




Custom Search