[PATCH] Implement D3DXQuaternionConjugate with a test

David Adam David.Adam at math.cnrs.fr
Thu Oct 18 13:28:36 CDT 2007


---
 dlls/d3dx8/tests/math.c |   14 +++++++++++++-
 include/d3dx8math.inl   |   10 ++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 92f0a82..10a2ad8 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -32,12 +32,24 @@
=20
 static void D3X8QuaternionTest(void)
 {
-    D3DXQUATERNION q, r;
+    D3DXQUATERNION expectedquat, gotquat, q, r;
+    LPD3DXQUATERNION funcpointer;
     FLOAT expected, got;
=20
     q.x =3D 1.0f, q.y =3D 2.0f; q.z =3D 4.0f; q.w =3D 10.0f;=20
     r.x =3D -3.0f; r.y =3D 4.0f; r.z =3D -5.0f; r.w =3D 7.0;
=20
+/*_______________D3DXQuaternionConjugate________________*/
+    expectedquat.x =3D -1.0f; expectedquat.y =3D -2.0f; expectedquat.z =3D =
-4.0f; expectedquat.w =3D 10.0f;
+    D3DXQuaternionConjugate(&gotquat,&q);
+    expect_vec4(expectedquat,gotquat);
+    /* Test the NULL case */
+    funcpointer =3D D3DXQuaternionConjugate(&gotquat,NULL);
+    ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+    funcpointer =3D D3DXQuaternionConjugate(NULL,NULL);
+    ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+
+
 /*_______________D3DXQuaternionDot______________________*/
     expected =3D 55.0f;
     got =3D D3DXQuaternionDot(&q,&r);
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 77c454c..95590cf 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -258,6 +258,16 @@ static inline D3DXVECTOR4* D3DXVec4Subtract(D3DXVECTOR4=
 *pout, CONST D3DXVECTOR4
=20
 /*__________________D3DXQUATERNION____________________*/
=20
+static inline D3DXQUATERNION* D3DXQuaternionConjugate(D3DXQUATERNION *pout,=
 CONST D3DXQUATERNION *pq)
+{
+    if ( !pout || !pq) return NULL;
+    pout->x =3D -pq->x;
+    pout->y =3D -pq->y;
+    pout->z =3D -pq->z;
+    pout->w =3D pq->w;
+    return pout;
+}
+
 static inline FLOAT D3DXQuaternionDot(CONST D3DXQUATERNION *pq1, CONST D3DX=
QUATERNION *pq2)
 {
     if ( !pq1 || !pq2 ) return 0.0f;
--=20
1.5.3.2


--=_29usucbyzvok--



More information about the wine-patches mailing list