[PATCH] Implement D3DXQuaterionMultiply with a test

David Adam David.Adam at math.cnrs.fr
Mon Nov 19 08:55:21 CST 2007


---
 dlls/d3dx8/d3dx8.spec   |    2 +-
 dlls/d3dx8/math.c       |    9 +++++++++
 dlls/d3dx8/tests/math.c |    5 +++++
 include/d3dx8math.h     |    1 +
 4 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index 4a6d26c..ea9d87f 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -53,7 +53,7 @@
 @ stub D3DXQuaternionRotationMatrix
 @ stub D3DXQuaternionRotationAxis
 @ stub D3DXQuaternionRotationYawPitchRoll
-@ stub D3DXQuaternionMultiply
+@ stdcall D3DXQuaternionMultiply(ptr ptr ptr)
 @ stdcall D3DXQuaternionNormalize(ptr ptr)
 @ stub D3DXQuaternionInverse
 @ stub D3DXQuaternionLn
diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index 3cff34f..242c2b1 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -581,6 +581,15 @@ D3DXPLANE* WINAPI D3DXPlaneTransform(D3DXPLANE *pout, C=
ONST D3DXPLANE *pplane, C
=20
 /*_________________D3DXQUATERNION________________*/
=20
+D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION * pout, CONST =
D3DXQUATERNION *pq1, CONST D3DXQUATERNION * pq2)
+{
+    pout->x =3D pq2->w * pq1->x + pq2->x * pq1->w + pq2->y * pq1->z - pq2->=
z * pq1->y;
+    pout->y =3D pq2->w * pq1->y - pq2->x * pq1->z + pq2->y * pq1->w + pq2->=
z * pq1->x;
+    pout->z =3D pq2->w * pq1->z + pq2->x * pq1->y - pq2->y * pq1->x + pq2->=
z * pq1->w;
+    pout->w =3D pq2->w * pq1->w - pq2->x * pq1->x - pq2->y * pq1->y - pq2->=
z * pq1->z;
+    return pout;
+}
+
 D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST =
D3DXQUATERNION *pq)
 {
     FLOAT norm;
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index f62bd80..fe9893b 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -622,6 +622,11 @@ static void D3X8QuaternionTest(void)
     got =3D D3DXQuaternionLengthSq(NULL);
     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", =
expected, got);
=20
+/*_______________D3DXQuaternionMultiply________________________*/
+    expectedquat.x =3D 3.0f; expectedquat.y =3D 61.0f; expectedquat.z =3D -=
32.0f; expectedquat.w =3D 85.0f;
+    D3DXQuaternionMultiply(&gotquat,&q,&r);
+    expect_vec4(expectedquat,gotquat);
+
 /*_______________D3DXQuaternionNormalize________________________*/
     expectedquat.x =3D 1.0f/11.0f; expectedquat.y =3D 2.0f/11.0f; expectedq=
uat.z =3D 4.0f/11.0f; expectedquat.w =3D 10.0f/11.0f;
     D3DXQuaternionNormalize(&gotquat,&q);
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index a3eca67..08c7c63 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -302,6 +302,7 @@ D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine(D3DXVECTOR3 *=
pout, CONST D3DXPLANE *p
 D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp);
 D3DXPLANE* WINAPI D3DXPlaneTransform(D3DXPLANE *pout, CONST D3DXPLANE *ppla=
ne, CONST D3DXMATRIX *pm);
=20
+D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION * pout, CONST =
D3DXQUATERNION *pq1, CONST D3DXQUATERNION * pq2);
 D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST =
D3DXQUATERNION *pq);
=20
 D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR=
2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g);
--=20
1.5.3.2


--=_2l4d4hpo57eo--



More information about the wine-patches mailing list