[PATCH] Implement D3DXMatrixRotationYawPitchRoll with a test

David Adam David.Adam at math.cnrs.fr
Sat Nov 3 03:30:14 CDT 2007


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

diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index 9d1efd2..c19c105 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -31,7 +31,7 @@
 @ stdcall D3DXMatrixRotationZ(ptr long)
 @ stdcall D3DXMatrixRotationAxis(ptr ptr long)
 @ stdcall D3DXMatrixRotationQuaternion(ptr ptr)
-@ stub D3DXMatrixRotationYawPitchRoll
+@ stdcall D3DXMatrixRotationYawPitchRoll(ptr long long long)
 @ stub D3DXMatrixTransformation
 @ stub D3DXMatrixAffineTransformation
 @ stub D3DXMatrixLookAtRH
diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index d7064a7..c81e621 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -111,6 +111,19 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationY(D3DXMATRIX *pout=
, FLOAT angle)
     return pout;
 }
=20
+D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *pout, FLOAT y=
aw, FLOAT pitch, FLOAT roll)
+{
+    D3DXMATRIX m, pout1, pout2, pout3;
+
+    D3DXMatrixIdentity(&pout3);
+    D3DXMatrixRotationZ(&m,roll);
+    D3DXMatrixMultiply(&pout2,&pout3,&m);
+    D3DXMatrixRotationX(&m,pitch);
+    D3DXMatrixMultiply(&pout1,&pout2,&m);
+    D3DXMatrixRotationY(&m,yaw);
+    D3DXMatrixMultiply(pout,&pout1,&m);
+    return pout;
+}
 D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle)
 {
     D3DXMatrixIdentity(pout);
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index a5e6e47..d79bfc7 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -236,6 +236,14 @@ static void D3DXMatrixTest(void)
     D3DXMatrixRotationY(&gotmat,angle);
     expect_mat(expectedmat,gotmat);
=20
+/*____________D3DXMatrixRotationYawPitchRoll____*/
+    expectedmat.m[0][0] =3D 0.888777f; expectedmat.m[0][1] =3D 0.091875f; e=
xpectedmat.m[0][2] =3D -0.449037f; expectedmat.m[0][3] =3D 0.0f;
+    expectedmat.m[1][0] =3D 0.351713f; expectedmat.m[1][1] =3D 0.491487f; e=
xpectedmat.m[1][2] =3D 0.796705f; expectedmat.m[1][3] =3D 0.0f;
+    expectedmat.m[2][0] =3D 0.293893f; expectedmat.m[2][1] =3D -0.866025f; =
expectedmat.m[2][2] =3D 0.404509f; expectedmat.m[2][3] =3D 0.0f;
+    expectedmat.m[3][0] =3D 0.0f; expectedmat.m[3][1] =3D 0.0f; expectedmat=
.m[3][2] =3D 0.0f; expectedmat.m[3][3] =3D 1.0f;
+    D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f*angle/5.0f, angle, 3.0f*an=
gle/17.0f);
+    expect_mat(expectedmat,gotmat);
+
 /*____________D3DXMatrixRotationZ______________*/
     expectedmat.m[0][0] =3D 0.5f; expectedmat.m[0][1] =3D sqrt(3.0f)/2.0f; =
expectedmat.m[0][2] =3D 0.0f; expectedmat.m[0][3] =3D 0.0f;
     expectedmat.m[1][0] =3D -sqrt(3.0f)/2.0f; expectedmat.m[1][1] =3D 0.5f;=
 expectedmat.m[1][2] =3D 0.0f; expectedmat.m[1][3] =3D 0.0f;
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 8e56970..657623c 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -64,6 +64,7 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationAxis(D3DXMATRIX *pout=
, CONST D3DXVECTOR3 *p
 D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion(D3DXMATRIX *pout, CONST D3D=
XQUATERNION *pq);
 D3DXMATRIX* WINAPI D3DXMatrixRotationX(D3DXMATRIX *pout, FLOAT angle);
 D3DXMATRIX* WINAPI D3DXMatrixRotationY(D3DXMATRIX *pout, FLOAT angle);
+D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *pout, FLOAT y=
aw, FLOAT pitch, FLOAT roll);
 D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle);
 D3DXMATRIX* WINAPI D3DXMatrixScaling(D3DXMATRIX *pout, FLOAT sx, FLOAT sy, =
FLOAT sz);
 D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y=
, FLOAT z);
--=20
1.5.3.2


--=_3g05fxtg1d2c--



More information about the wine-patches mailing list