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

d3dx8: Implement D3DXQuaternionExp.

parent 41029cc8
......@@ -57,7 +57,7 @@
@ stdcall D3DXQuaternionNormalize(ptr ptr)
@ stdcall D3DXQuaternionInverse(ptr ptr)
@ stdcall D3DXQuaternionLn(ptr ptr)
@ stub D3DXQuaternionExp
@ stdcall D3DXQuaternionExp(ptr ptr)
@ stdcall D3DXQuaternionSlerp(ptr ptr ptr long)
@ stdcall D3DXQuaternionSquad(ptr ptr ptr ptr ptr long)
@ stdcall D3DXQuaternionBaryCentric(ptr ptr ptr ptr long long)
......
......@@ -588,6 +588,28 @@ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric(D3DXQUATERNION *pout, CONST D3D
return pout;
}
D3DXQUATERNION* WINAPI D3DXQuaternionExp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq)
{
FLOAT norm;
norm = sqrt(pq->x * pq->x + pq->y * pq->y + pq->z * pq->z);
if (norm )
{
pout->x = sin(norm) * pq->x / norm;
pout->y = sin(norm) * pq->y / norm;
pout->z = sin(norm) * pq->z / norm;
pout->w = cos(norm);
}
else
{
pout->x = 0.0f;
pout->y = 0.0f;
pout->z = 0.0f;
pout->w = 1.0f;
}
return pout;
}
D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq)
{
D3DXQUATERNION temp;
......
......@@ -595,6 +595,20 @@ static void D3X8QuaternionTest(void)
got = D3DXQuaternionDot(NULL,NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXQuaternionExp______________________________*/
expectedquat.x = -0.216382f; expectedquat.y = -0.432764f; expectedquat.z = -0.8655270f; expectedquat.w = -0.129449f;
D3DXQuaternionExp(&gotquat,&q);
expect_vec4(expectedquat,gotquat);
/* Test the null quaternion */
expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
D3DXQuaternionExp(&gotquat,&nul);
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.195366; expectedquat.y = 0.097683f; expectedquat.z = 0.293049f; expectedquat.w = 0.930813f;
D3DXQuaternionExp(&gotquat,&Nq1);
expect_vec4(expectedquat,gotquat);
/*_______________D3DXQuaternionIdentity________________*/
expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
D3DXQuaternionIdentity(&gotquat);
......
......@@ -303,6 +303,7 @@ D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp);
D3DXPLANE* WINAPI D3DXPlaneTransform(D3DXPLANE *pout, CONST D3DXPLANE *pplane, CONST D3DXMATRIX *pm);
D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, FLOAT f, FLOAT g);
D3DXQUATERNION* WINAPI D3DXQuaternionExp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
D3DXQUATERNION* WINAPI D3DXQuaternionLn(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2);
......
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