XMQuaternionSquad 函式 (directxmath.h)

使用球面四元數插補,在四個單位四元數之間插補。

語法

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

參數

[in] Q0

第一個單位四元數。

[in] Q1

第二個單位四元數。

[in] Q2

第三個單位四元數。

[in] Q3

第四個單位四元數。

[in] t

插補控制因素。

傳回值

傳回插補四元數。 如果 Q0Q1Q2Q3 不是所有單位四元數,則傳回的四元數未定義。

備註

DirectXMath 四元數函式會使用 XMVECTOR 4 向量來代表四元數,其中 X、Y 和 Z 元件是向量元件,而 W 元件是純量部分。

使用此方法需要一些設定,才能使用。 如需詳細資訊 ,請參閱 XMQuaternionSquadSetup

下列範例示範如何使用一組四元數索引鍵 (Q0、Q1、Q2、Q3) 來計算 A、B、C) 的內部四邊軸 (點。 這可確保正切值在相鄰區段之間是連續的。

// 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

平臺需求

支援 Win32 傳統型應用程式、Windows 市集應用程式和 Windows Phone 8 個應用程式。

需求

   
目標平台 Windows
標頭 directxmath.h

另請參閱