David Adam : d3dx8: Implement D3DXQuaternionMultiply.
Alexandre Julliard
julliard at winehq.org
Tue Nov 20 10:55:00 CST 2007
Module: wine
Branch: master
Commit: 45b13a6cabff57b48b26f2b8e7c58c3838fcb3d8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=45b13a6cabff57b48b26f2b8e7c58c3838fcb3d8
Author: David Adam <David.Adam at math.cnrs.fr>
Date: Mon Nov 19 15:55:21 2007 +0100
d3dx8: Implement D3DXQuaternionMultiply.
---
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, CONST D3DXPLANE *pplane, C
/*_________________D3DXQUATERNION________________*/
+D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION * pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION * pq2)
+{
+ pout->x = pq2->w * pq1->x + pq2->x * pq1->w + pq2->y * pq1->z - pq2->z * pq1->y;
+ pout->y = pq2->w * pq1->y - pq2->x * pq1->z + pq2->y * pq1->w + pq2->z * pq1->x;
+ pout->z = pq2->w * pq1->z + pq2->x * pq1->y - pq2->y * pq1->x + pq2->z * pq1->w;
+ pout->w = 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 = D3DXQuaternionLengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
+/*_______________D3DXQuaternionMultiply________________________*/
+ expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f;
+ D3DXQuaternionMultiply(&gotquat,&q,&r);
+ expect_vec4(expectedquat,gotquat);
+
/*_______________D3DXQuaternionNormalize________________________*/
expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 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 *pplane, CONST D3DXMATRIX *pm);
+D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION * pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION * pq2);
D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g);
More information about the wine-cvs
mailing list