From 909b5023600bc7432c17cb57e28dce05cef66272 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 19 Apr 2007 21:13:51 +0200 Subject: [PATCH] d3drm: Implement D3DRMQuaternionFromRotation. --- dlls/d3drm/d3drm.spec | 2 +- dlls/d3drm/math.c | 8 ++++++++ dlls/d3drm/tests/vector.c | 24 ++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/dlls/d3drm/d3drm.spec b/dlls/d3drm/d3drm.spec index a8133ab7ea1..8713d0180ff 100644 --- a/dlls/d3drm/d3drm.spec +++ b/dlls/d3drm/d3drm.spec @@ -5,7 +5,7 @@ @ stub D3DRMCreateColorRGB @ stub D3DRMCreateColorRGBA @ stdcall D3DRMMatrixFromQuaternion(ptr ptr) -@ stub D3DRMQuaternionFromRotation +@ stdcall D3DRMQuaternionFromRotation(ptr ptr long) @ stdcall D3DRMQuaternionMultiply(ptr ptr ptr) @ stub D3DRMQuaternionSlerp @ stdcall D3DRMVectorAdd(ptr ptr ptr) diff --git a/dlls/d3drm/math.c b/dlls/d3drm/math.c index 714f35f6e43..21a4151d04c 100644 --- a/dlls/d3drm/math.c +++ b/dlls/d3drm/math.c @@ -70,6 +70,14 @@ void WINAPI D3DRMMatrixFromQuaternion(D3DRMMATRIX4D m, LPD3DRMQUATERNION q) m[3][3] = 1.0; } +/* Return a unit quaternion that represents a rotation of an angle around an axis */ +LPD3DRMQUATERNION WINAPI D3DRMQuaternionFromRotation(LPD3DRMQUATERNION q, LPD3DVECTOR v, D3DVALUE theta) +{ + q->s = cos(theta/2.0); + D3DRMVectorScale(&q->v, D3DRMVectorNormalize(v), sin(theta/2.0)); + return q; +} + /* Add Two Vectors */ LPD3DVECTOR WINAPI D3DRMVectorAdd(LPD3DVECTOR d, LPD3DVECTOR s1, LPD3DVECTOR s2) { diff --git a/dlls/d3drm/tests/vector.c b/dlls/d3drm/tests/vector.c index b71805b3b84..744eb16efbc 100644 --- a/dlls/d3drm/tests/vector.c +++ b/dlls/d3drm/tests/vector.c @@ -50,6 +50,15 @@ gotmat[3][0],gotmat[3][1],gotmat[3][2],gotmat[3][3] ); \ } +#define expect_quat(expectedquat,gotquat) \ + ok( (fabs(expectedquat.v.x-gotquat.v.x)