Commit a3634e2c authored by David Adam's avatar David Adam Committed by Alexandre Julliard

d3dx9: Fix D3DXQuaternionToAxisAngle to make tests pass in Windows.

parent 8f1836cb
......@@ -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_____________________*/
......
......@@ -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);
......
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