Commit 4099eb8b authored by Nozomi Kodama's avatar Nozomi Kodama Committed by Alexandre Julliard

d3dx9_36: D3DXQuaternionLn computes as if the norm of the input is 1.

parent a8139f0b
......@@ -1215,29 +1215,20 @@ D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUA
D3DXQUATERNION* WINAPI D3DXQuaternionLn(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq)
{
FLOAT norm, normvec, theta;
FLOAT t;
norm = D3DXQuaternionLengthSq(pq);
if ( norm > 1.0001f )
{
pout->x = pq->x;
pout->y = pq->y;
pout->z = pq->z;
pout->w = 0.0f;
}
else if( norm > 0.99999f)
{
normvec = sqrt( pq->x * pq->x + pq->y * pq->y + pq->z * pq->z );
theta = atan2(normvec, pq->w) / normvec;
pout->x = theta * pq->x;
pout->y = theta * pq->y;
pout->z = theta * pq->z;
pout->w = 0.0f;
}
TRACE("(%p, %p)\n", pout, pq);
if ( (pq->w >= 1.0f) || (pq->w == -1.0f) )
t = 1.0f;
else
{
FIXME("The quaternion (%f, %f, %f, %f) has a norm <1. This should not happen. Windows returns a result anyway. This case is not implemented yet.\n", pq->x, pq->y, pq->z, pq->w);
}
t = acos( pq->w ) / sqrt( 1.0f - pq->w * pq->w );
pout->x = t * pq->x;
pout->y = t * pq->y;
pout->z = t * pq->z;
pout->w = 0.0f;
return pout;
}
......
......@@ -746,11 +746,24 @@ static void D3DXQuaternionTest(void)
expectedquat.x = 0.093768f; expectedquat.y = 0.187536f; expectedquat.z = 0.375073f; expectedquat.w = 0.0f;
D3DXQuaternionLn(&gotquat,&Nq);
expect_vec4(expectedquat,gotquat);
/* Test the cas where the norm of the quaternion is <1 */
Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
Nq.x = 0.0f; Nq.y = 0.0f; Nq.z = 0.0f; Nq.w = 1.0f;
expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
D3DXQuaternionLn(&gotquat,&Nq);
expect_vec4(expectedquat,gotquat);
Nq.x = 5.4f; Nq.y = 1.2f; Nq.z = -0.3f; Nq.w = -0.3f;
expectedquat.x = 10.616652f; expectedquat.y = 2.359256f; expectedquat.z = -0.589814f; expectedquat.w = 0.0f;
D3DXQuaternionLn(&gotquat,&Nq);
expect_vec4(expectedquat,gotquat);
/* Test the case where the norm of the quaternion is <1 */
Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w = 0.9f;
expectedquat.x = 0.206945f; expectedquat.y = 0.103473f; expectedquat.z = 0.310418f; expectedquat.w = 0.0f;
D3DXQuaternionLn(&gotquat,&Nq1);
todo_wine{ expect_vec4(expectedquat,gotquat) };
expect_vec4(expectedquat,gotquat);
/* Test the case where the real part of the quaternion is -1.0f */
Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w = -1.0f;
expectedquat.x = 0.2f; expectedquat.y = 0.1f; expectedquat.z = 0.3f; expectedquat.w = 0.0f;
D3DXQuaternionLn(&gotquat,&Nq1);
expect_vec4(expectedquat,gotquat);
/*_______________D3DXQuaternionMultiply________________________*/
expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f;
......
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