UnsafeNativeMethods.Vector3.Hermite Method

Language:

Performs a Hermite spline interpolation using the specified 3-D vectors.

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 Function Hermite( _
    ByVal pOut As Vector3, _
    ByVal pPosition As Vector3, _
    ByVal pTangent As Vector3, _
    ByVal pPosition2 As Vector3, _
    ByVal pTangent2 As Vector3, _
    ByVal weightingFactor As Single _
) As Vector3
C# public static Vector3 Hermite(
    Vector3 pOut,
    Vector3 pPosition,
    Vector3 pTangent,
    Vector3 pPosition2,
    Vector3 pTangent2,
    float weightingFactor
);
C++ public:
static Vector3 Hermite(
    Vector3 pOut,
    Vector3 pPosition,
    Vector3 pTangent,
    Vector3 pPosition2,
    Vector3 pTangent2,
    float weightingFactor
);
JScript public static function Hermite(
    pOut : Vector3,
    pPosition : Vector3,
    pTangent : Vector3,
    pPosition2 : Vector3,
    pTangent2 : Vector3,
    weightingFactor : float
) : Vector3;

Parameters

pOut Microsoft.DirectX.Vector3
A Vector3 structure that is the result of the Hermite spline interpolation.
pPosition Microsoft.DirectX.Vector3
Source Vector3 structure that is a position vector.
pTangent Microsoft.DirectX.Vector3
Source Vector3 structure that is a tangent vector.
pPosition2 Microsoft.DirectX.Vector3
Source Vector3 structure that is a position vector.
pTangent2 Microsoft.DirectX.Vector3
Source Vector3 structure that is a tangent vector.
weightingFactor System.Single
Weighting factor. See Remarks.

Return Value

Microsoft.DirectX.Vector3
A Vector3 structure that is the result of the Hermite spline interpolation.

Remarks

The Hermite method interpolates from (pPosition, pTangent) to (pPosition2, pTangent2) using Hermite spline interpolation.

The spline interpolation is a generalization of the ease-in, ease-out spline. The ramp is a function of Q(s) with the following properties.

Q(s) = As3 + Bs2 + Cs + D (and therefore, Q'(s) = 3As2 + 2Bs + C)

a) Q(0) = v1, so Q'(0) = t1

b) Q(1) = v2, so Q'(1) = t2

In these properties, v1 is the contents of pPosition, v2 is the contents of pPosition2, t1 is the contents of pTangent, t2 is the contents of pTangent2, and s is the contents of weightingFactor.

These properties are used to solve for A, B, C, D in the following example.

D = v1  (from a)
C = t1  (from a)
3A + 2B = t2 - t-1 (substituting for C)
A + B = v2 - v1 - t1 (substituting for C and D)

To generate Q(s), pass in the solutions for A, B, C, and D as follows.

A = 2v1 - 2v2 + t2 + t1 
B = 3v2 - 3v1 - 2t1 - t2
C = t1 
D = v1

These properties yield the following:

Q(s) = (2v1 - 2v2 + t2 + t1)s3 + (3v2 - 3v1 - 2t1 - t2)s2 + t1s + v1.
Which can be rearranged as:
Q(s) = (2s3 - 3s2 + 1)v1 + (-2s3 + 3s2)v2 + (s3 - 2s2 + s)t1 + (s3 - s2)t2.

Hermite splines are useful for controlling animation because the curve runs through all of the control points. Also, because the position and tangent are explicitly specified at the ends of each segment, it is easy to create a continuous curve, provided that the starting position and tangent match the ending values of the last segment.

The return value for this method is the same value returned in the pOut parameter. This allows you to use the Hermite method as a parameter for another method.

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