Quaternion.SquadSetup Method |
Language: |
Sets up control points for spherical quadrangle interpolation.
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(
Quaternion% outA,
Quaternion% outB,
Quaternion% outC,
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
);
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.
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 : q3Having 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 = q2Note: In the preceding example, Ln is the application programming interface (API) method Quaternion.Ln, and Exp is the API method Quaternion.Exp.
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 Q3The following C# code example shows how you can interpolate between Q1 and Q2.[C#]Note:
// 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);The result is a rotation of 45 degrees around the z-axis for time = 0.5.
- C is +/- Q2 depending on the result of the function
- Qt is the result of the function
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