Expand Minimize

D3DXVec4Hermite function

Performs a Hermite spline interpolation, using the specified 4D vectors.

Syntax


D3DXVECTOR4* D3DXVec4Hermite(
  _Inout_  D3DXVECTOR4 *pOut,
  _In_     const D3DXVECTOR4 *pV1,
  _In_     const D3DXVECTOR4 *pT1,
  _In_     const D3DXVECTOR4 *pV2,
  _In_     const D3DXVECTOR4 *pT2,
  _In_     FLOAT s
);

Parameters

pOut [in, out]

Type: D3DXVECTOR4*

Pointer to the D3DXVECTOR4 structure that is the result of the operation.

pV1 [in]

Type: const D3DXVECTOR4*

Pointer to a source D3DXVECTOR4 structure, a position vector.

pT1 [in]

Type: const D3DXVECTOR4*

Pointer to a source D3DXVECTOR4 structure, a tangent vector.

pV2 [in]

Type: const D3DXVECTOR4*

Pointer to a source D3DXVECTOR4 structure, a position vector.

pT2 [in]

Type: const D3DXVECTOR4*

Pointer to a source D3DXVECTOR4 structure, a tangent vector.

s [in]

Type: FLOAT

Weighting factor. See Remarks.

Return value

Type: D3DXVECTOR4*

Pointer to a D3DXVECTOR4 structure that is the result of the Hermite spline interpolation.

Remarks

The D3DXVec4Hermite function interpolates from (positionA, tangentA) to (positionB, tangentB) 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

v1 is the contents of pV1, v2 in the contents of pV2, t1 is the contents of pT1, and t2 is the contents of pT2.

These properties are used to solve for A, B, C, D.

Plug in the solutions for A,B,C and D to generate Q(s).

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

This yields:

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 the control points. Also, because the position and tangent are explicitly specified at the ends of each segment, it is easy to create a C2 continuous curve as long as you make sure that your starting position and tangent match the ending values of the last segment.

The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXVec4Hermite function can be used as a parameter for another function.

Requirements

Header

D3dx9math.h

Library

D3dx9.lib

 

 

Community Additions

ADD
Show:
© 2014 Microsoft