Commit 7a4490c0 authored by David Adam's avatar David Adam Committed by Alexandre Julliard

d3dx8: Implement D3DXQuaternionToAxisAngle.

parent aa30f442
......@@ -49,7 +49,7 @@
@ stdcall D3DXMatrixOrthoOffCenterLH(ptr long long long long long long)
@ stdcall D3DXMatrixShadow(ptr ptr ptr)
@ stdcall D3DXMatrixReflect(ptr ptr)
@ stub D3DXQuaternionToAxisAngle
@ stdcall D3DXQuaternionToAxisAngle(ptr ptr ptr)
@ stub D3DXQuaternionRotationMatrix
@ stub D3DXQuaternionRotationAxis
@ stub D3DXQuaternionRotationYawPitchRoll
......
......@@ -665,6 +665,27 @@ D3DXQUATERNION* WINAPI D3DXQuaternionSquad(D3DXQUATERNION *pout, CONST D3DXQUATE
return pout;
}
void WINAPI D3DXQuaternionToAxisAngle(CONST D3DXQUATERNION *pq, D3DXVECTOR3 *paxis, FLOAT *pangle)
{
FLOAT norm;
*pangle = 0.0f;
norm = D3DXQuaternionLength(pq);
if ( norm )
{
paxis->x = pq->x / norm;
paxis->y = pq->y / norm;
paxis->z = pq->z / norm;
if ( fabs( pq->w ) <= 1.0f ) *pangle = 2.0f * acos(pq->w);
}
else
{
paxis->x = 1.0f;
paxis->y = 0.0f;
paxis->z = 0.0f;
}
}
/*_________________D3DXVec2_____________________*/
D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g)
......
......@@ -552,9 +552,10 @@ static void D3DXPlaneTest(void)
static void D3X8QuaternionTest(void)
{
D3DXQUATERNION expectedquat, gotquat, nul, q, r, s, t, u;
D3DXQUATERNION expectedquat, gotquat, Nq, nul, q, r, s, t, u;
LPD3DXQUATERNION funcpointer;
FLOAT expected, got, scale, scale2;
D3DXVECTOR3 axis, expectedvec;
FLOAT angle, expected, got, scale, scale2;
BOOL expectedbool, gotbool;
nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
......@@ -667,6 +668,26 @@ static void D3X8QuaternionTest(void)
expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f;
D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale);
expect_vec4(expectedquat,gotquat);
/*_______________D3DXQuaternionToAxisAngle__________________*/
Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f;
expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f;
expected = 2.197869f;
D3DXQuaternionToAxisAngle(&Nq,&axis,&angle);
expect_vec3(expectedvec,axis);
ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
/* Test if |w|>1.0f */
expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f;
expected = 0.0f;
D3DXQuaternionToAxisAngle(&q,&axis,&angle);
expect_vec3(expectedvec,axis);
ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
/* Test the null quaternion */
expectedvec.x = 1.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
expected = 0.0f;
D3DXQuaternionToAxisAngle(&nul,&axis,&angle);
expect_vec3(expectedvec,axis);
ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
}
static void D3X8Vector2Test(void)
......
......@@ -308,6 +308,7 @@ D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION *pout, CONST D3DXQU
D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
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);
D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g);
D3DXVECTOR2* WINAPI D3DXVec2CatmullRom(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv0, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment