XMQuaternionSlerp

Interpolates between two unit quaternions, using spherical linear interpolation.

Syntax

XMVECTOR XMQuaternionSlerp(
         XMVECTOR Q0,
         XMVECTOR Q1,
         float t
)  

Parameters

Q0
Type: XMVECTOR 

Unit quaternion to interpolate from.

Q1
Type: XMVECTOR 

Unit quaternion to interpolate to.

t
Type: float 

Interpolation control factor.

Return value

Type: XMVECTOR 

Returns the interpolated quaternion. If Q0 and Q1 are not unit quaternions, the resulting interpolation is undefined.

Remarks

The DirectXMath quaternion functions use an XMVECTOR 4-vector to represent quaternions, where the X, Y, and Z components are the vector part and the W component is the scalar part.

When t is 0.0f, the function returns Q0. When t is 1.0f, the function returns Q1.

Using nlerp instead of slerp

In most use-cases, slerp (spherical linear interpolation) is unnecessary and can be easily and efficiently approximated by nlerp (normalized linear interpolation). nlerp is implemented as follows:

XMQuaternionNormalize( XMVectorLerp( Q0, Q1, t ) );  

See XMVectorLerp and XMQuaternionNormalize. For more information, see Understanding Slerp, Then Not Using It.

Requirements

Header: Declared in directxmath.h.