David Adam : d3dx8: Implement D3DXQuaternionRotationYawPitchRoll.

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


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

Author: David Adam <David.Adam at math.cnrs.fr>
Date:   Tue Nov 20 15:23:36 2007 +0100

d3dx8: Implement D3DXQuaternionRotationYawPitchRoll.

---

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

diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index 4e7996a..d398791 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -52,7 +52,7 @@
 @ stdcall D3DXQuaternionToAxisAngle(ptr ptr ptr)
 @ stdcall D3DXQuaternionRotationMatrix(ptr ptr)
 @ stdcall D3DXQuaternionRotationAxis(ptr ptr long)
-@ stub D3DXQuaternionRotationYawPitchRoll
+@ stdcall D3DXQuaternionRotationYawPitchRoll(ptr long long long)
 @ stdcall D3DXQuaternionMultiply(ptr ptr ptr)
 @ stdcall D3DXQuaternionNormalize(ptr ptr)
 @ stdcall D3DXQuaternionInverse(ptr ptr)
diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index f1cbf22..aa8664f 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -706,6 +706,15 @@ D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix(D3DXQUATERNION *pout, CONST
     return pout;
 }
 
+D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll(D3DXQUATERNION *pout, FLOAT yaw, FLOAT pitch, FLOAT roll)
+{
+    pout->x = sin( yaw / 2.0f) * cos(pitch / 2.0f) * sin(roll / 2.0f) + cos(yaw / 2.0f) * sin(pitch / 2.0f) * cos(roll / 2.0f);
+    pout->y = sin( yaw / 2.0f) * cos(pitch / 2.0f) * cos(roll / 2.0f) - cos(yaw / 2.0f) * sin(pitch / 2.0f) * sin(roll / 2.0f);
+    pout->z = cos(yaw / 2.0f) * cos(pitch / 2.0f) * sin(roll / 2.0f) - sin( yaw / 2.0f) * sin(pitch / 2.0f) * cos(roll / 2.0f);
+    pout->w = cos( yaw / 2.0f) * cos(pitch / 2.0f) * cos(roll / 2.0f) + sin(yaw / 2.0f) * sin(pitch / 2.0f) * sin(roll / 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 6a63fd8..950bc5e 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -701,6 +701,12 @@ static void D3X8QuaternionTest(void)
     D3DXQuaternionRotationMatrix(&gotquat,&mat);
     expect_vec4(expectedquat,gotquat);
 
+/*_______________D3DXQuaternionRotationYawPitchRoll__________*/
+    expectedquat.x = 0.303261f; expectedquat.y = 0.262299f; expectedquat.z = 0.410073f; expectedquat.w = 0.819190f;
+    D3DXQuaternionRotationYawPitchRoll(&gotquat,D3DX_PI/4.0f,D3DX_PI/11.0f,D3DX_PI/3.0f);
+    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 f9bc777..5ef85b4 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -308,6 +308,7 @@ D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION *pout, CONST D3DXQU
 D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
 D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis(D3DXQUATERNION *pout, CONST D3DXVECTOR3 *pv, FLOAT angle);
 D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix(D3DXQUATERNION *pout, CONST D3DXMATRIX *pm);
+D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll(D3DXQUATERNION *pout, FLOAT yaw, FLOAT pitch, FLOAT roll);
 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