XMQuaternionSquad function (directxmath.h)

Interpolates between four unit quaternions, using spherical quadrangle interpolation.

Syntax

XMVECTOR XM_CALLCONV XMQuaternionSquad(
  [in] FXMVECTOR Q0,
  [in] FXMVECTOR Q1,
  [in] FXMVECTOR Q2,
  [in] GXMVECTOR Q3,
  [in] float     t
) noexcept;

Parameters

[in] Q0

First unit quaternion.

[in] Q1

Second unit quaternion.

[in] Q2

Third unit quaternion.

[in] Q3

Fourth unit quaternion.

[in] t

Interpolation control factor.

Return value

Returns the interpolated quaternion. If Q0, Q1, Q2, and Q3 are not all unit quaternions, the returned quaternion 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.

The use of this method requires some setup before its use. See XMQuaternionSquadSetup for details.

The following example shows how to use a set of quaternion keys (Q0, Q1, Q2, Q3) to compute the inner quadrangle points (A, B, C). This ensures that the tangents are continuous across adjacent segments.

// Rotation about the z-axis
XMVECTOR Q0 = XMVectorSet(0,  0, 0.707f, -.707f);
XMVECTOR Q1 = XMVectorSet(0,  0, 0.000f, 1.000f);
XMVECTOR Q2 = XMVectorSet(0,  0, 0.707f, 0.707f);
XMVECTOR Q3 = XMVectorSet(0,  0, 1.000f, 0.000f);

XMVECTOR A, B, C;
XMQuaternionSquadSetup(&A, &B, &C, Q0, Q1, Q2, Q3);

XMVECTOR result = XMQuaternionSquad(Q1, A, B, C, 0.5f);
// result is a rotation of 45 degrees around the z-axis

Platform Requirements

Supported for Win32 desktop apps, Windows Store apps, and Windows Phone 8 apps.

Requirements

Requirement Value
Target Platform Windows
Header directxmath.h

See also