d3dx8: Implement D3DX*LengthSq.

This commit is contained in:
David Adam 2007-10-18 17:47:50 +02:00 committed by Alexandre Julliard
parent d6377d2fd8
commit bf9a690dbc
2 changed files with 43 additions and 2 deletions

View File

@ -41,6 +41,15 @@ static void D3X8QuaternionTest(void)
expected=0.0f;
got = D3DXQuaternionLength(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXQuaternionLengthSq________________________*/
expected = 121.0f;
got = D3DXQuaternionLengthSq(&q);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/* Tests the case NULL */
expected=0.0f;
got = D3DXQuaternionLengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
}
static void D3X8Vector2Test(void)
@ -172,6 +181,15 @@ static void D3X8Vector3Test(void)
expected=0.0f;
got = D3DXVec3Length(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXVec3LengthSq________________________*/
expected = 121.0f;
got = D3DXVec3LengthSq(&u);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/* Tests the case NULL */
expected=0.0f;
got = D3DXVec3LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
}
static void D3X8Vector4Test(void)
@ -189,6 +207,15 @@ static void D3X8Vector4Test(void)
expected=0.0f;
got = D3DXVec4Length(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXVec4LengthSq________________________*/
expected = 121.0f;
got = D3DXVec4LengthSq(&u);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/* Tests the case NULL */
expected=0.0f;
got = D3DXVec4LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
}
START_TEST(math)

View File

@ -101,6 +101,12 @@ static inline FLOAT D3DXVec3Length(CONST D3DXVECTOR3 *pv)
return sqrt( (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) );
}
static inline FLOAT D3DXVec3LengthSq(CONST D3DXVECTOR3 *pv)
{
if (!pv) return 0.0f;
return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z);
}
/*__________________D3DXVECTOR4_______________________*/
static inline FLOAT D3DXVec4Length(CONST D3DXVECTOR4 *pv)
@ -109,6 +115,11 @@ static inline FLOAT D3DXVec4Length(CONST D3DXVECTOR4 *pv)
return sqrt( (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) + (pv->w) * (pv->w) );
}
static inline FLOAT D3DXVec4LengthSq(CONST D3DXVECTOR4 *pv)
{
if (!pv) return 0.0f;
return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) + (pv->w) * (pv->w);
}
/*__________________D3DXQUATERNION____________________*/
@ -118,7 +129,10 @@ static inline FLOAT D3DXQuaternionLength( CONST D3DXQUATERNION *pq)
return sqrt( (pq->x) * (pq->x) + (pq->y) * (pq->y) + (pq->z) * (pq->z) + (pq->w) * (pq->w) );
}
static inline FLOAT D3DXQuaternionLengthSq( CONST D3DXQUATERNION *pq)
{
if (!pq) return 0.0f;
return (pq->x) * (pq->x) + (pq->y) * (pq->y) + (pq->z) * (pq->z) + (pq->w) * (pq->w);
}
#endif