From 77f5d4c88c02287f852c961962e3e9c12570c91d Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 18 Oct 2007 20:28:36 +0200 Subject: [PATCH] d3dx8: Implement D3DXQuaternionConjugate. --- dlls/d3dx8/tests/math.c | 14 +++++++++++++- include/d3dx8math.inl | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c index b7302b17504..8c5baa3d166 100644 --- a/dlls/d3dx8/tests/math.c +++ b/dlls/d3dx8/tests/math.c @@ -32,12 +32,24 @@ static void D3X8QuaternionTest(void) { - D3DXQUATERNION q, r; + D3DXQUATERNION expectedquat, gotquat, q, r; + LPD3DXQUATERNION funcpointer; FLOAT expected, got; q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f; r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0; +/*_______________D3DXQuaternionConjugate________________*/ + expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f; + D3DXQuaternionConjugate(&gotquat,&q); + expect_vec4(expectedquat,gotquat); + /* Test the NULL case */ + funcpointer = D3DXQuaternionConjugate(&gotquat,NULL); + ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer); + funcpointer = D3DXQuaternionConjugate(NULL,NULL); + ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer); + + /*_______________D3DXQuaternionDot______________________*/ expected = 55.0f; got = D3DXQuaternionDot(&q,&r); diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl index 87e12899332..a2fd8bfbd12 100644 --- a/include/d3dx8math.inl +++ b/include/d3dx8math.inl @@ -258,6 +258,16 @@ static inline D3DXVECTOR4* D3DXVec4Subtract(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 /*__________________D3DXQUATERNION____________________*/ +static inline D3DXQUATERNION* D3DXQuaternionConjugate(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq) +{ + if ( !pout || !pq) return NULL; + pout->x = -pq->x; + pout->y = -pq->y; + pout->z = -pq->z; + pout->w = pq->w; + return pout; +} + static inline FLOAT D3DXQuaternionDot(CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2) { if ( !pq1 || !pq2 ) return 0.0f;