Quaternion.SquadSetup(Quaternion,Quaternion,Quaternion,Quaternion,Quaternion,Quaternion,Quaternion) Method (Microsoft.DirectX)

Sets up control points for spherical quadrangle interpolation.

Definition

Visual Basic Public Shared Sub SquadSetup( _
    ByRef outA As Quaternion, _
    ByRef outB As Quaternion, _
    ByRef outC As Quaternion, _
    ByVal q0 As Quaternion, _
    ByVal q1 As Quaternion, _
    ByVal q2 As Quaternion, _
    ByVal q3 As Quaternion _
)
C# public static void SquadSetup(
    ref Quaternion outA,
    ref Quaternion outB,
    ref Quaternion outC,
    Quaternion q0,
    Quaternion q1,
    Quaternion q2,
    Quaternion q3
);
C++ public:
static void SquadSetup(
    QuaternionoutA,
    QuaternionoutB,
    QuaternionoutC,
    Quaternion q0,
    Quaternion q1,
    Quaternion q2,
    Quaternion q3
);
JScript public static function SquadSetup(
    outA : Quaternion,
    outB : Quaternion,
    outC : Quaternion,
    q0 : Quaternion,
    q1 : Quaternion,
    q2 : Quaternion,
    q3 : Quaternion
);

Parameters

outA Microsoft.DirectX.Quaternion
A Quaternion instance that represents the outA value.
outB Microsoft.DirectX.Quaternion
A Quaternion instance that represents the outB value.
outC Microsoft.DirectX.Quaternion
A Quaternion instance that represents the outC value.
q0 Microsoft.DirectX.Quaternion
A Quaternion instance that represents the q0 input control point.
q1 Microsoft.DirectX.Quaternion
A Quaternion instance that represents the q1 input control point.
q2 Microsoft.DirectX.Quaternion
A Quaternion instance that represents the q2 input control point.
q3 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 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.