d3dx9: Fix D3DXQuaternionToAxisAngle to make tests pass in Windows.

This commit is contained in:
David Adam 2009-07-15 21:04:01 +02:00 committed by Alexandre Julliard
parent 8f1836cbcc
commit a3634e2ca3
2 changed files with 8 additions and 22 deletions

View File

@ -1373,23 +1373,10 @@ D3DXQUATERNION* WINAPI D3DXQuaternionSquad(D3DXQUATERNION *pout, CONST D3DXQUATE
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;
}
paxis->x = pq->x;
paxis->y = pq->y;
paxis->z = pq->z;
*pangle = 2.0f * acos(pq->w);
}
/*_________________D3DXVec2_____________________*/

View File

@ -938,20 +938,19 @@ static void D3DXQuaternionTest(void)
/*_______________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;
expectedvec.x = 1.0f/22.0f; expectedvec.y = 2.0f/22.0f; expectedvec.z = 4.0f/22.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;
expectedvec.x = 1.0f; expectedvec.y = 2.0f; expectedvec.z = 4.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;
expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
expected = 3.141593f;
D3DXQuaternionToAxisAngle(&nul,&axis,&angle);
expect_vec3(expectedvec,axis);
ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);