Setup control points for spherical quadrangle interpolation.

Syntax

```void D3DXQuaternionSquadSetup(          D3DXQUATERNION *pAOut,
D3DXQUATERNION *pBOut,
D3DXQUATERNION *pCOut,
const D3DXQUATERNION *pQ0,
const D3DXQUATERNION *pQ1,
const D3DXQUATERNION *pQ2,
const D3DXQUATERNION *pQ3
);```

Parameters

pAOut
[out] Pointer to AOut.
pBOut
[out] Pointer to BOut.
pCOut
[out] Pointer to COut.
pQ0
[in] Pointer to the input control point, Q0.
pQ1
[in] Pointer to the input control point, Q1.
pQ2
[in] Pointer to the input control point, Q2.
pQ3
[in] Pointer to the input control point, Q3.

Return Value

None.

Remarks

This function takes four control points, which are supplied to the inputs pQ0, pQ1, pQ2, and pQ3. 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

Note  Ln is the application programming interface (API) method D3DXQuaternionLn and Exp is the API method D3DXQuaternionExp.

Examples

The following example shows how to use a set of quaternion keys (Q0, Q1, Q2, Q3) to compute the inner quadrangle points (A, B, C). This ensures that the tangents are continuous across adjacent segments.

```        A     B
Q0    Q1    Q2    Q3
```

This is how you can interpolate between Q1 and Q2.

```// Rotation about the z-axis
D3DXQUATERNION Q0 = D3DXQUATERNION(0,  0, 0.707f, -.707f);
D3DXQUATERNION Q1 = D3DXQUATERNION(0,  0, 0.000f, 1.000f);
D3DXQUATERNION Q2 = D3DXQUATERNION(0,  0, 0.707f, 0.707f);
D3DXQUATERNION Q3 = D3DXQUATERNION(0,  0, 1.000f, 0.000f);
D3DXQUATERNION A, B, C, Qt;
FLOAT time = 0.5f;

D3DXQuaternionSquadSetup(&A, &B, &C, &Q0, &Q1, &Q2, &Q3);
D3DXQuaternionSquad(&Qt, &Q1, &A, &B, &C, time);
```

Note:

• C is +/- Q2 depending on the result of the function
• Qt is the result of the function

The result is a rotation of 45 degrees around the z-axis for time = 0.5.

Function Information