Microsoft DirectX 8.1 (Visual Basic) |
Setup control points for spherical quadrangle interpolation.
D3DXQuaternionSquadSetup( _ AOut As D3DXQUATERNION*, _ BOut As D3DXQUATERNION*, _ COut As D3DXQUATERNION*, _ Q0 As CONST D3DXQUATERNION*, _ Q1 As CONST D3DXQUATERNION*, _ Q2 As CONST D3DXQUATERNION*, _ Q3 As CONST D3DXQUATERNION*)
If the function fails, an error is raised and Err.Number can be set to one of the following values.
D3DERR_INVALIDCALL |
D3DERR_OUTOFVIDEOMEMORY |
For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.
This function takes the four control points supplied by Q0, Q1, Q2, and Q3. The function then alters these values to find a curve that flows along the shortest path. The values of Q0, Q2, and Q3 are calculated as shown below.
Q0 = |Q0 + Q1| < |Q0 - Q1| ? -Q0 : Q0 Q2 = |Q1 + Q2| < |Q1 - Q2| ? -Q2 : Q2 Q3 = |Q2 + Q3| < |Q2 - Q3| ? -Q3 : Q3
Having calculated the new Q values, the values for AOut, BOut, and COut are calculated as shown below.
AOut = Q1 * e[-0.25 *( Ln[Exp(Q1)*Q2] + Ln[Exp(Q1)*Q0] ) ] BOut = Q2 * e[-0.25 *( Ln[Exp(Q2)*Q3] + Ln[Exp(Q2)*Q1] ) ] COut = Q2 where: Ln is the API method D3DXQuaternionLn Exp is the API method D3DXQuaternionExp
Use a set of quaternion keys (q0, q1, q2, ..., qn) to compute the inner quadrangle points (a1, a2, a3, ..., an-1) as shown in the following example. This will ensure that the tangents are continuous across adjacent segments.
a1 a2 a3 q0 q1 q2 q3 q4 a[i] = q[i] * exp( -(ln(inv(q[i])*q[i+1]) + ln(inv(q[i])*q[i-1])) / 4 )
Once the values for a (a1, a2, a3 in this case) are computed, the results are used to interpolate along the curve.
qt = Squad(t, q[i], a[i], a[i+1], q[i+1])