David Adam : d3dx8: Implement D3DXQuaternionRotationAxis.

Alexandre Julliard julliard at winehq.org
Mon Nov 26 08:16:21 CST 2007


Module: wine
Branch: master
Commit: 345994fbcec4783657b7982ab3ce3f0bc3c53cae
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=345994fbcec4783657b7982ab3ce3f0bc3c53cae

Author: David Adam <David.Adam at math.cnrs.fr>
Date:   Tue Nov 20 13:04:16 2007 +0100

d3dx8: Implement D3DXQuaternionRotationAxis.

---

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

diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index 1c57f53..d3b0ffa 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -51,7 +51,7 @@
 @ stdcall D3DXMatrixReflect(ptr ptr)
 @ stdcall D3DXQuaternionToAxisAngle(ptr ptr ptr)
 @ stub D3DXQuaternionRotationMatrix
-@ stub D3DXQuaternionRotationAxis
+@ stdcall D3DXQuaternionRotationAxis(ptr ptr long)
 @ stub D3DXQuaternionRotationYawPitchRoll
 @ stdcall D3DXQuaternionMultiply(ptr ptr ptr)
 @ stdcall D3DXQuaternionNormalize(ptr ptr)
diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index 52e580d..adc100d 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -643,6 +643,18 @@ D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQ
     return pout;
 }
 
+D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis(D3DXQUATERNION *pout, CONST D3DXVECTOR3 *pv, FLOAT angle)
+{
+    D3DXVECTOR3 temp;
+
+    D3DXVec3Normalize(&temp, pv);
+    pout->x = sin( angle / 2.0f ) * temp.x;
+    pout->y = sin( angle / 2.0f ) * temp.y;
+    pout->z = sin( angle / 2.0f ) * temp.z;
+    pout->w = cos( angle / 2.0f );
+    return pout;
+}
+
 D3DXQUATERNION* WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, FLOAT t)
 {
     FLOAT dot, epsilon;
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index e3c6a28..589bb2a 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -656,6 +656,18 @@ static void D3X8QuaternionTest(void)
     D3DXQuaternionNormalize(&gotquat,&nul);
     expect_vec4(expectedquat,gotquat);
 
+/*_______________D3DXQuaternionRotationAxis___________________*/
+    axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f;
+    angle = D3DX_PI/3.0f;
+    expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f;
+    D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
+    expect_vec4(expectedquat,gotquat);
+ /* Test the nul quaternion */
+    axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f;
+    expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f;
+    D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
+    expect_vec4(expectedquat,gotquat);
+
 /*_______________D3DXQuaternionSlerp________________________*/
     expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f;
     D3DXQuaternionSlerp(&gotquat,&q,&r,scale);
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index dd85e3a..c5f18a2 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -306,6 +306,7 @@ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric(D3DXQUATERNION *pout, CONST D3D
 D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
 D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2);
 D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
+D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis(D3DXQUATERNION *pout, CONST D3DXVECTOR3 *pv, FLOAT angle);
 D3DXQUATERNION* WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, FLOAT t);
 D3DXQUATERNION* WINAPI D3DXQuaternionSquad(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, CONST D3DXQUATERNION *pq4, FLOAT t);
 void WINAPI D3DXQuaternionToAxisAngle(CONST D3DXQUATERNION *pq, D3DXVECTOR3 *paxis, FLOAT *pangle);




More information about the wine-cvs mailing list