UnsafeNativeMethods.Quaternion.SquadSetup Method

Language:

Sets up control points for spherical quadrangle interpolation.

Note: For programming in Microsoft Visual Basic .NET or Microsoft JScript .NET, use the equivalent method in the Microsoft.DirectX structures.

Definition

Visual Basic Public Shared Sub SquadSetup( _
    ByVal pOutA As Quaternion, _
    ByVal pOutB As Quaternion, _
    ByVal pOutC As Quaternion, _
    ByVal pQ0 As Quaternion, _
    ByVal pQ1 As Quaternion, _
    ByVal pQ2 As Quaternion, _
    ByVal pQ3 As Quaternion _
)
C# public static void SquadSetup(
    Quaternion pOutA,
    Quaternion pOutB,
    Quaternion pOutC,
    Quaternion pQ0,
    Quaternion pQ1,
    Quaternion pQ2,
    Quaternion pQ3
);
C++ public:
static void SquadSetup(
    Quaternion pOutA,
    Quaternion pOutB,
    Quaternion pOutC,
    Quaternion pQ0,
    Quaternion pQ1,
    Quaternion pQ2,
    Quaternion pQ3
);
JScript public static function SquadSetup(
    pOutA : Quaternion,
    pOutB : Quaternion,
    pOutC : Quaternion,
    pQ0 : Quaternion,
    pQ1 : Quaternion,
    pQ2 : Quaternion,
    pQ3 : Quaternion
);

Parameters

pOutA Microsoft.DirectX.Quaternion
A Quaternion instance that represents the outA value.
pOutB Microsoft.DirectX.Quaternion
A Quaternion instance that represents the outB value.
pOutC Microsoft.DirectX.Quaternion
A Quaternion instance that represents the outC value.
pQ0 Microsoft.DirectX.Quaternion
A Quaternion instance that represents the q0 input control point.
pQ1 Microsoft.DirectX.Quaternion
A Quaternion instance that represents the q1 input control point.
pQ2 Microsoft.DirectX.Quaternion
A Quaternion instance that represents the q2 input control point.
pQ3 Microsoft.DirectX.Quaternion
A Quaternion instance that represents the q3 input control point.

Remarks

This method takes four control points, which are supplied to the inputs as q0, q1, q2, and q3, and alters their 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 outA, outB, and outC are calculated as shown below.
outA = q1 * exp[-0.25 *( Ln[Exp(q1)*q2] + Ln[Exp(q1)*q0] ) ]

outB = q2 * exp[-0.25 *( Ln[Exp(q2)*q3] + Ln[Exp(q2)*q1] ) ]

outC = q2
Note: In the preceding example, Ln is the application programming interface (API) method Quaternion.Ln, and Exp is the API method Quaternion.Exp.

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
The following C# code example shows how you can interpolate between Q1 and Q2.
[C#]
// Rotation about the z-axis Quaternion Q0 = new Quaternion(0f, 0f, 0.707f, -.707f); Quaternion Q1 = new Quaternion(0f, 0f, 0.000f, 1.000f); Quaternion Q2 = new Quaternion(0f, 0f, 0.707f, 0.707f); Quaternion Q3 = new Quaternion(0f, 0f, 1.000f, 0.000f); Quaternion A = new Quaternion(); Quaternion B = new Quaternion(); Quaternion C = new Quaternion(); Quaternion Qt = new Quaternion(); Single time = 0.5f; Quaternion.SquadSetup(ref A, ref B, ref C, Q0, Q1, Q2, Q3); Qt = Quaternion.Squad(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.

See Also


Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.

Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center