d3dx8: Implement D3DXQuaternionRotationAxis.

This commit is contained in:
David Adam 2007-11-20 13:04:16 +01:00 committed by Alexandre Julliard
parent 7a4490c062
commit 345994fbce
4 changed files with 26 additions and 1 deletions

View File

@ -51,7 +51,7 @@
@ stdcall D3DXMatrixReflect(ptr ptr)
@ stdcall D3DXQuaternionToAxisAngle(ptr ptr ptr)
@ stub D3DXQuaternionRotationMatrix
@ stub D3DXQuaternionRotationAxis
@ stdcall D3DXQuaternionRotationAxis(ptr ptr long)
@ stub D3DXQuaternionRotationYawPitchRoll
@ stdcall D3DXQuaternionMultiply(ptr ptr ptr)
@ stdcall D3DXQuaternionNormalize(ptr ptr)

View File

@ -643,6 +643,18 @@ D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQ
return pout;
}
D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis(D3DXQUATERNION *pout, CONST D3DXVECTOR3 *pv, FLOAT angle)
{
D3DXVECTOR3 temp;
D3DXVec3Normalize(&temp, pv);
pout->x = sin( angle / 2.0f ) * temp.x;
pout->y = sin( angle / 2.0f ) * temp.y;
pout->z = sin( angle / 2.0f ) * temp.z;
pout->w = cos( angle / 2.0f );
return pout;
}
D3DXQUATERNION* WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, FLOAT t)
{
FLOAT dot, epsilon;

View File

@ -656,6 +656,18 @@ static void D3X8QuaternionTest(void)
D3DXQuaternionNormalize(&gotquat,&nul);
expect_vec4(expectedquat,gotquat);
/*_______________D3DXQuaternionRotationAxis___________________*/
axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f;
angle = D3DX_PI/3.0f;
expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f;
D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
expect_vec4(expectedquat,gotquat);
/* Test the nul quaternion */
axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f;
expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f;
D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
expect_vec4(expectedquat,gotquat);
/*_______________D3DXQuaternionSlerp________________________*/
expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f;
D3DXQuaternionSlerp(&gotquat,&q,&r,scale);

View File

@ -306,6 +306,7 @@ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric(D3DXQUATERNION *pout, CONST D3D
D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2);
D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis(D3DXQUATERNION *pout, CONST D3DXVECTOR3 *pv, FLOAT angle);
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);