XMQuaternionBaryCentric 函式 (directxmath.h)

使用指定的四元數傳回直心座標中的點。

語法

XMVECTOR XM_CALLCONV XMQuaternionBaryCentric(
  [in] FXMVECTOR Q0,
  [in] FXMVECTOR Q1,
  [in] FXMVECTOR Q2,
  [in] float     f,
  [in] float     g
) noexcept;

參數

[in] Q0

三角形中的第一個四元數。

[in] Q1

三角形中的第二個四元數。

[in] Q2

三角形中的第三個四元數。

[in] f

加權因數。 請參閱備註。

[in] g

加權因數。 請參閱備註。

傳回值

傳回直心座標中的四元數。

備註

下列虛擬程式碼示範函式的作業。


XMVECTOR Result;
XMVECTOR QA, QB;
float s = f + g;

if (s != 0.0f)
{
    QA = XMQuaternionSlerp(Q0, Q1, s);
    QB = XMQuaternionSlerp(Q0, Q2, s);
    Result = XMQuaternionSlerp(QA, QB, g / s);
}
else
{
    Result.x = Q0.x;
    Result.y = Q0.y;
    Result.z = Q0.z;
    Result.w = Q0.w;
}

return Result;
        

請注意,Barycentric 座標適用于「平面」表面,但不適用於「弧形」表面。 因此,此函式是一些因應措施。 混合 3 四元數的替代方法是由下列程式碼所提供:


inline XMVECTOR XMQuaternionBlend(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, float w1, float w2)
{
    // Note if you choose one of the three weights to be zero, you get a blend of two
    //  quaternions.  This does not give you slerp of those quaternions.
    float w0 = 1.0f - w1 - w2;
    XMVECTOR Result = XMVector4Normalize(
        XMVectorScale(Q0, w0) +
        XMVectorScale(Q1, w1) +
        XMVectorScale(Q2, w2));
    return Result;
}
        

平臺需求

Microsoft Visual Studio 2010 或 Microsoft Visual Studio 2012 搭配 Windows SDK for Windows 8。 支援 Win32 傳統型應用程式、Windows 市集應用程式和 Windows Phone 8 個應用程式。

需求

   
目標平台 Windows
標頭 directxmath.h

另請參閱

DirectXMath 程式庫四元數函數

XMQuaternionBaryCentricV