UnsafeNativeMethods.Vector2.CatmullRom(Vector2,Vector2,Vector2,Vector2,Vector2,Single) Method (Microsoft.DirectX)

Performs a Catmull-Rom interpolation using specified 2-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 CatmullRom( _
    ByVal pOut As Vector2, _
    ByVal pPosition1 As Vector2, _
    ByVal pPosition2 As Vector2, _
    ByVal pPosition3 As Vector2, _
    ByVal pPosition4 As Vector2, _
    ByVal weightingFactor As Single _
) As Vector2
C# public static Vector2 CatmullRom(
    Vector2 pOut,
    Vector2 pPosition1,
    Vector2 pPosition2,
    Vector2 pPosition3,
    Vector2 pPosition4,
    float weightingFactor
);
C++ public:
static Vector2 CatmullRom(
    Vector2 pOut,
    Vector2 pPosition1,
    Vector2 pPosition2,
    Vector2 pPosition3,
    Vector2 pPosition4,
    float weightingFactor
);
JScript public static function CatmullRom(
    pOut : Vector2,
    pPosition1 : Vector2,
    pPosition2 : Vector2,
    pPosition3 : Vector2,
    pPosition4 : Vector2,
    weightingFactor : float
) : Vector2;

Parameters

pOut Microsoft.DirectX.Vector2
A Vector2 structure that is the result of the Catmull-Rom interpolation.
pPosition1 Microsoft.DirectX.Vector2
Source Vector2 structure that is a position vector.
pPosition2 Microsoft.DirectX.Vector2
Source Vector2 structure that is a position vector.
pPosition3 Microsoft.DirectX.Vector2
Source Vector2 structure that is a position vector.
pPosition4 Microsoft.DirectX.Vector2
Source Vector2 structure that is a position vector.
weightingFactor System.Single
Weighting factor. See Remarks.

Return Value

Microsoft.DirectX.Vector2
A Vector2 structure that is the result of the Catmull-Rom interpolation.

Remarks

To derive the Catmull-Rom spline from the Hermite spline, use the following settings. In this example, v1 is the contents of pPosition1, v2 is the contents of pPosition2, p3 is the contents of pPosition3, p4 is the contents of pPosition4, and s is the contents of weightingFactor.

v1 = p2
v2 = p3
t1 = (p3 - p1) / 2
t2 = (p4 - p2) / 2

Using the Hermite spline equation:

Q(s) = (2s3 - 3s2 + 1)v1 + (-2s3 + 3s2)v2 + (s3 - 2s2 + s)t1 + (s3 - s2)t2

and substituting for v1, v2, t1, t2 yields:

Q(s) = (2s3 - 3s2 + 1)p2 + (-2s3 + 3s2)p3 + (s3 - 2s2 + s)(p3 - p1) / 2 + (s3 - s2)(p4 - p2)/2

This can be rearranged as:

Q(s) = [(-s3 + 2s2 - s)p1 + (3s3 - 5s2 + 2)p2 + (-3s3 + 4s2 + s)p3 + (s3 - s2)p4] / 2

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

See Also