[PATCH] Implement D3DXQuaternionRotationYawPitchRoll with a test
David Adam
David.Adam at math.cnrs.fr
Tue Nov 20 08:23:36 CST 2007
---
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(D3D=
XQUATERNION *pout, CONST
return pout;
}
=20
+D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll(D3DXQUATERNION *p=
out, FLOAT yaw, FLOAT pitch, FLOAT roll)
+{
+ pout->x =3D sin( yaw / 2.0f) * cos(pitch / 2.0f) * sin(roll / 2.0f) + c=
os(yaw / 2.0f) * sin(pitch / 2.0f) * cos(roll / 2.0f);
+ pout->y =3D sin( yaw / 2.0f) * cos(pitch / 2.0f) * cos(roll / 2.0f) - c=
os(yaw / 2.0f) * sin(pitch / 2.0f) * sin(roll / 2.0f);
+ pout->z =3D cos(yaw / 2.0f) * cos(pitch / 2.0f) * sin(roll / 2.0f) - si=
n( yaw / 2.0f) * sin(pitch / 2.0f) * cos(roll / 2.0f);
+ pout->w =3D cos( yaw / 2.0f) * cos(pitch / 2.0f) * cos(roll / 2.0f) + s=
in(yaw / 2.0f) * sin(pitch / 2.0f) * sin(roll / 2.0f);
+ return pout;
+}
+
D3DXQUATERNION* WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pout, CONST D3DX=
QUATERNION *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);
=20
+/*_______________D3DXQuaternionRotationYawPitchRoll__________*/
+ expectedquat.x =3D 0.303261f; expectedquat.y =3D 0.262299f; expectedqua=
t.z =3D 0.410073f; expectedquat.w =3D 0.819190f;
+ D3DXQuaternionRotationYawPitchRoll(&gotquat,D3DX_PI/4.0f,D3DX_PI/11.0f,=
D3DX_PI/3.0f);
+ expect_vec4(expectedquat,gotquat);
+
+
/*_______________D3DXQuaternionSlerp________________________*/
expectedquat.x =3D -0.2f; expectedquat.y =3D 2.6f; expectedquat.z =3D 1=
.3f; expectedquat.w =3D 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(D3DXQUATER=
NION *pout, CONST D3DXQU
D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST =
D3DXQUATERNION *pq);
D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis(D3DXQUATERNION *pout, CON=
ST D3DXVECTOR3 *pv, FLOAT angle);
D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix(D3DXQUATERNION *pout, C=
ONST D3DXMATRIX *pm);
+D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll(D3DXQUATERNION *p=
out, FLOAT yaw, FLOAT pitch, FLOAT roll);
D3DXQUATERNION* WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pout, CONST D3DX=
QUATERNION *pq1, CONST D3DXQUATERNION *pq2, FLOAT t);
D3DXQUATERNION* WINAPI D3DXQuaternionSquad(D3DXQUATERNION *pout, CONST D3DX=
QUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, CONST=
D3DXQUATERNION *pq4, FLOAT t);
void WINAPI D3DXQuaternionToAxisAngle(CONST D3DXQUATERNION *pq, D3DXVECTOR3=
*paxis, FLOAT *pangle);
--=20
1.5.3.2
--=_6q0bxild6ts8--
More information about the wine-patches
mailing list