Share via


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;
}
        

플랫폼 요구 사항

Windows 8용 Windows SDK를 사용하는 Microsoft Visual Studio 2010 또는 Microsoft Visual Studio 2012. Win32 데스크톱 앱, Windows 스토어 앱 및 Windows Phone 8개 앱에서 지원됩니다.

요구 사항

   
대상 플랫폼 Windows
헤더 directxmath.h

추가 정보

DirectXMath 라이브러리 Quaternion 함수

XMQuaternionBaryCentricV