Vector3.CatmullRom Method |
Language: |
Performs a Catmull-Rom interpolation using specified 3-D vectors.
Visual Basic Public Shared Function CatmullRom( _
ByVal position1 As Vector3, _
ByVal position2 As Vector3, _
ByVal position3 As Vector3, _
ByVal position4 As Vector3, _
ByVal weightingFactor As Single _
) As Vector3C# public static Vector3 CatmullRom(
Vector3 position1,
Vector3 position2,
Vector3 position3,
Vector3 position4,
float weightingFactor
);C++ public:
static Vector3 CatmullRom(
Vector3 position1,
Vector3 position2,
Vector3 position3,
Vector3 position4,
float weightingFactor
);JScript public static function CatmullRom(
position1 : Vector3,
position2 : Vector3,
position3 : Vector3,
position4 : Vector3,
weightingFactor : float
) : Vector3;
position1 Microsoft.DirectX.Vector3
Source Vector3 structure that is a position vector.position2 Microsoft.DirectX.Vector3
Source Vector3 structure that is a position vector.position3 Microsoft.DirectX.Vector3
Source Vector3 structure that is a position vector.position4 Microsoft.DirectX.Vector3
Source Vector3 structure that is a position vector.weightingFactor System.Single
Weighting factor. See Remarks.
Microsoft.DirectX.Vector3
A Vector3 structure that is the result of the Catmull-Rom interpolation.
To derive the Catmull-Rom spline from the Hermite spline, use the following settings. In this example, v1 is the contents of position1, v2 is the contents of position2, p3 is the contents of position3, p4 is the contents of position4, and s is the contents of weightingFactor.
v1 = p2 v2 = p3 t1 = (p3 - p1) / 2 t2 = (p4 - p2) / 2Using the Hermite spline equation.
Q(s) = (2s3 - 3s2 + 1)v1 + (-2s3 + 3s2)v2 + (s3 - 2s2 + s)t1 + (s3 - s2)t2Substituting for v1, v2, t1, t2 yields the following result.Q(s) = (2s3 - 3s2 + 1)p2 + (-2s3 + 3s2)p3 + (s3 - 2s2 + s)(p3 - p1) / 2 + (s3 - s2)(p4 - p2)/2This result can be rearranged as follows:Q(s) = [(-s3 + 2s2 - s)p1 + (3s3 - 5s2 + 2)p2 + (-3s3 + 4s2 + s)p3 + (s3 - s2)p4] / 2
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