/* AUTOMATICALLY GENERATED FILE - DO NOT EDIT! Please change MatrixNxN.py and re-run it */ /* Generated with ./VectorN.py n = 3, TYPE = float */ #include "ZUnitTest.hpp" #include #include #include #include #include static const char* testSST_Math_Vec3fAdd(); static const char* testSST_Math_Vec3fAddLocal(); static const char* testSST_Math_Vec3fSubtract(); static const char* testSST_Math_Vec3fSubtractLocal(); static const char* testSST_Math_Vec3fMultiply(); static const char* testSST_Math_Vec3fMultiplyLocal(); static const char* testSST_Math_Vec3fScale(); static const char* testSST_Math_Vec3fScaleLocal(); static const char* testSST_Math_Vec3fDivide(); static const char* testSST_Math_Vec3fDivideLocal(); static const char* testSST_Math_Vec3fAbs(); static const char* testSST_Math_Vec3fAbsLocal(); static const char* testSST_Math_Vec3fNegate(); static const char* testSST_Math_Vec3fNegateLocal(); static const char* testSST_Math_Vec3fBias(); static const char* testSST_Math_Vec3fBiasLocal(); static const char* testSST_Math_Vec3fRecip(); static const char* testSST_Math_Vec3fRecipLocal(); static const char* testSST_Math_Vec3fRecipSqrt(); static const char* testSST_Math_Vec3fRecipSqrtLocal(); static const char* testSST_Math_Vec3fSqrt(); static const char* testSST_Math_Vec3fSqrtLocal(); static const char* testSST_Math_Vec3fSqrt(); static const char* testSST_Math_Vec3fSqrtLocal(); static const char* testSST_Math_Vec3fCross(); static const char* testSST_Math_Vec3fCrossLocal(); static const char* testSST_Math_Vec3fRotateAbout(); static const char* testSST_Math_Vec3fRotateAboutLocal(); static const char* testSST_Math_Vec3fProject(); static const char* testSST_Math_Vec3fProjectLocal(); static const char* testSST_Math_Vec3fMagnitude(); static const char* testSST_Math_Vec3fNormalize(); static const char* testSST_Math_Vec3fNormalizeLocal(); static const char* testSST_Math_Vec3fMagnitudeSquared(); static const char* testSST_Math_Vec3fDot(); // List of unit tests ZUnitTest SST_Math_Vec3fUnitTests[] = { { "testSST_Math_Vec3fAdd " , testSST_Math_Vec3fAdd }, { "testSST_Math_Vec3fAddLocal " , testSST_Math_Vec3fAddLocal }, { "testSST_Math_Vec3fSubtract " , testSST_Math_Vec3fSubtract }, { "testSST_Math_Vec3fSubtractLocal " , testSST_Math_Vec3fSubtractLocal }, { "testSST_Math_Vec3fMultiply " , testSST_Math_Vec3fMultiply }, { "testSST_Math_Vec3fMultiplyLocal " , testSST_Math_Vec3fMultiplyLocal }, { "testSST_Math_Vec3fScale " , testSST_Math_Vec3fScale }, { "testSST_Math_Vec3fScaleLocal " , testSST_Math_Vec3fScaleLocal }, { "testSST_Math_Vec3fDivide " , testSST_Math_Vec3fDivide }, { "testSST_Math_Vec3fDivideLocal " , testSST_Math_Vec3fDivideLocal }, { "testSST_Math_Vec3fAbs " , testSST_Math_Vec3fAbs }, { "testSST_Math_Vec3fAbsLocal " , testSST_Math_Vec3fAbsLocal }, { "testSST_Math_Vec3fNegate " , testSST_Math_Vec3fNegate }, { "testSST_Math_Vec3fNegateLocal " , testSST_Math_Vec3fNegateLocal }, { "testSST_Math_Vec3fBias " , testSST_Math_Vec3fBias }, { "testSST_Math_Vec3fBiasLocal " , testSST_Math_Vec3fBiasLocal }, { "testSST_Math_Vec3fRecip " , testSST_Math_Vec3fRecip }, { "testSST_Math_Vec3fRecipLocal " , testSST_Math_Vec3fRecipLocal }, { "testSST_Math_Vec3fRecipSqrt " , testSST_Math_Vec3fRecipSqrt }, { "testSST_Math_Vec3fRecipSqrtLocal " , testSST_Math_Vec3fRecipSqrtLocal }, { "testSST_Math_Vec3fSqrt " , testSST_Math_Vec3fSqrt }, { "testSST_Math_Vec3fSqrtLocal " , testSST_Math_Vec3fSqrtLocal }, { "testSST_Math_Vec3fSqrt " , testSST_Math_Vec3fSqrt }, { "testSST_Math_Vec3fSqrtLocal " , testSST_Math_Vec3fSqrtLocal }, { "testSST_Math_Vec3fMagnitude " , testSST_Math_Vec3fMagnitude }, { "testSST_Math_Vec3fNormalize " , testSST_Math_Vec3fNormalize }, { "testSST_Math_Vec3fNormalizeLocal " , testSST_Math_Vec3fNormalizeLocal }, { "testSST_Math_Vec3fCross " , testSST_Math_Vec3fCross }, { "testSST_Math_Vec3fCrossLocal " , testSST_Math_Vec3fCrossLocal }, { "testSST_Math_Vec3fRotateAbout " , testSST_Math_Vec3fRotateAbout }, { "testSST_Math_Vec3fRotateAboutLocal " , testSST_Math_Vec3fRotateAboutLocal }, { "testSST_Math_Vec3fProject " , testSST_Math_Vec3fProject }, { "testSST_Math_Vec3fProjectLocal " , testSST_Math_Vec3fProjectLocal }, { "testSST_Math_Vec3fMagnitudeSquared " , testSST_Math_Vec3fMagnitudeSquared }, { "testSST_Math_Vec3fDot " , testSST_Math_Vec3fDot } }; DECLARE_ZTESTBLOCK(SST_Math_Vec3f) /******************************************************************************/ static const char* testSST_Math_Vec3fAdd() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = -17.000000f; x.v[1] = -13.000000f; x.v[2] = -8.000000f; y.v[0] = 13.000000f; y.v[1] = 8.000000f; y.v[2] = 14.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [-17. -13. -8.] [ 13. 8. 14.] [-4. -5. 6.] */ SST_Math_Vec3fAdd(&x,&y,&w); TASSERT(fabsf((w.v[0])-(-4.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(-5.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(6.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fAddLocal() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 7.000000f; x.v[1] = 16.000000f; x.v[2] = -8.000000f; y.v[0] = -20.000000f; y.v[1] = -16.000000f; y.v[2] = 14.000000f; /* [ 7. 16. -8.] [-20. -16. 14.] [-13. 0. 6.] */ SST_Math_Vec3fAddLocal(&x,&y); /* for accuracy */ TASSERT(fabsf((x.v[0])-(-13.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(0.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(6.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fSubtract() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 4.000000f; x.v[1] = -2.000000f; x.v[2] = -12.000000f; y.v[0] = -5.000000f; y.v[1] = 19.000000f; y.v[2] = 13.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [ 4. -2. -12.] [ -5. 19. 13.] [ 9. -21. -25.] */ SST_Math_Vec3fSubtract(&x,&y,&w); TASSERT(fabsf((w.v[0])-(9.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(-21.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(-25.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fSubtractLocal() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ /* Resetting test vectors */ x.v[0] = -6.000000f; x.v[1] = -2.000000f; x.v[2] = -17.000000f; y.v[0] = -15.000000f; y.v[1] = 3.000000f; y.v[2] = -1.000000f; /* [ -6. -2. -17.] [-15. 3. -1.] [ 9. -5. -16.] */ SST_Math_Vec3fSubtractLocal(&x,&y); /* for accuracy */ TASSERT(fabsf((x.v[0])-(9.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(-5.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(-16.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fMultiply() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = -19.000000f; x.v[1] = -16.000000f; x.v[2] = 15.000000f; y.v[0] = -13.000000f; y.v[1] = 6.000000f; y.v[2] = 12.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [-19. -16. 15.] [-13. 6. 12.] [ 247. -96. 180.] */ SST_Math_Vec3fMultiply(&x,&y,&w); TASSERT(fabsf((w.v[0])-(247.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(-96.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(180.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fMultiplyLocal() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ /* Resetting test vectors */ x.v[0] = -1.000000f; x.v[1] = -14.000000f; x.v[2] = 1.000000f; y.v[0] = 9.000000f; y.v[1] = -16.000000f; y.v[2] = -20.000000f; /* [ -1. -14. 1.] [ 9. -16. -20.] [ -9. 224. -20.] */ SST_Math_Vec3fMultiplyLocal(&x,&y); /* for accuracy */ TASSERT(fabsf((x.v[0])-(-9.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(224.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(-20.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fDivide() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 15.000000f; x.v[1] = 11.000000f; x.v[2] = 31.000000f; y.v[0] = 16.000000f; y.v[1] = 16.000000f; y.v[2] = 17.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [ 15. 11. 31.] [ 16. 16. 17.] [ 0.9375 0.6875 1.82352936] */ SST_Math_Vec3fDivide(&x,&y,&w); TASSERT(fabsf((w.v[0])-(0.937500f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(0.687500f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(1.823529f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fDivideLocal() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 1.000000f; x.v[1] = 2.000000f; x.v[2] = 3.000000f; y.v[0] = 15.000000f; y.v[1] = 14.000000f; y.v[2] = 1.000000f; /* [ 1. 2. 3.] [ 15. 14. 1.] [ 0.06666667 0.14285715 3. ] */ SST_Math_Vec3fDivideLocal(&x,&y); /* for accuracy */ TASSERT(fabsf((x.v[0])-(0.066667f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(0.142857f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(3.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fScale() { SST_Vec3f x; /* 3 vector */ SST_Vec3f w; /* 3 vector */ float a; /* scalar */ /* Resetting test vectors */ x.v[0] = -17.000000f; x.v[1] = 10.000000f; x.v[2] = -11.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; a = 2.000000f; /* [-17. 10. -11.] [-34. 20. -22.] */ SST_Math_Vec3fScale(&x,a,&w); TASSERT(fabsf((w.v[0])-(-34.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(20.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(-22.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fScaleLocal() { SST_Vec3f x; /* 3 vector */ float a; /* scalar */ /* Resetting test vectors */ x.v[0] = -19.000000f; x.v[1] = -14.000000f; x.v[2] = 18.000000f; a = 2.000000f; /* [-19. -14. 18.] [-38. -28. 36.] */ SST_Math_Vec3fScaleLocal(&x,a); /* for accuracy */ TASSERT(fabsf((x.v[0])-(-38.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(-28.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(36.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fAbs() { SST_Vec3f x; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 16.000000f; x.v[1] = 6.000000f; x.v[2] = -2.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [ 16. 6. -2.] [ 16. 6. 2.] */ SST_Math_Vec3fAbs(&x,&w); TASSERT(fabsf((w.v[0])-(16.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(6.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(2.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fAbsLocal() { SST_Vec3f x; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 11.000000f; x.v[1] = 18.000000f; x.v[2] = -7.000000f; /* [ 11. 18. -7.] [ 11. 18. 7.] */ SST_Math_Vec3fAbsLocal(&x); /* for accuracy */ TASSERT(fabsf((x.v[0])-(11.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(18.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(7.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fBias() { SST_Vec3f x; /* 3 vector */ SST_Vec3f w; /* 3 vector */ float a; /* scalar */ /* Resetting test vectors */ x.v[0] = 18.000000f; x.v[1] = 12.000000f; x.v[2] = -1.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; a = 15.000000f; /* [ 18. 12. -1.] [ 36. 24. -2.] */ SST_Math_Vec3fBias(&x,a,&w); TASSERT(fabsf((w.v[0])-(33.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(27.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(14.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fBiasLocal() { SST_Vec3f x; /* 3 vector */ float a; /* scalar */ /* Resetting test vectors */ x.v[0] = -18.000000f; x.v[1] = 18.000000f; x.v[2] = -1.000000f; a = -10.000000f; /* [-18. 18. -1.] [-36. 36. -2.] */ SST_Math_Vec3fBiasLocal(&x,a); /* for accuracy */ TASSERT(fabsf((x.v[0])-(-28.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(8.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(-11.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fNegate() { SST_Vec3f x; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = -4.000000f; x.v[1] = 2.000000f; x.v[2] = -5.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [-4. 2. -5.] [ 4. -2. 5.] */ SST_Math_Vec3fNegate(&x,&w); TASSERT(fabsf((w.v[0])-(4.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(-2.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(5.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fNegateLocal() { SST_Vec3f x; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 9.000000f; x.v[1] = 7.000000f; x.v[2] = -6.000000f; /* [ 9. 7. -6.] [-9. -7. 6.] */ SST_Math_Vec3fNegateLocal(&x); /* for accuracy */ TASSERT(fabsf((x.v[0])-(-9.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(-7.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(6.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fSqrt() { SST_Vec3f x; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 33.000000f; x.v[1] = 37.000000f; x.v[2] = 27.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [ 33. 37. 27.] [ 5.74456263 6.08276272 5.19615221] */ SST_Math_Vec3fSqrt(&x,&w); TASSERT(fabsf((w.v[0])-(5.744563f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(6.082763f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(5.196152f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fSqrtLocal() { SST_Vec3f x; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 2.000000f; x.v[1] = 36.000000f; x.v[2] = 13.000000f; /* [ 2. 36. 13.] [ 1.41421354 6. 3.60555124] */ SST_Math_Vec3fSqrtLocal(&x); /* for accuracy */ TASSERT(fabsf((x.v[0])-(1.414214f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(6.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(3.605551f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fRecipSqrt() { SST_Vec3f x; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 17.000000f; x.v[1] = 2.000000f; x.v[2] = 27.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [ 17. 2. 27.] [ 0.24253564 0.70710677 0.19245009] */ SST_Math_Vec3fRecipSqrt(&x,&w); TASSERT(fabsf((w.v[0])-(0.242536f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(0.707107f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(0.192450f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fRecipSqrtLocal() { SST_Vec3f x; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 30.000000f; x.v[1] = 6.000000f; x.v[2] = 33.000000f; /* [ 30. 6. 33.] [ 0.18257418 0.40824828 0.17407766] */ SST_Math_Vec3fRecipSqrtLocal(&x); /* for accuracy */ TASSERT(fabsf((x.v[0])-(0.182574f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(0.408248f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(0.174078f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fRecip() { SST_Vec3f x; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 35.000000f; x.v[1] = 9.000000f; x.v[2] = 8.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [ 35. 9. 8.] [ 0.02857143 0.11111111 0.125 ] */ SST_Math_Vec3fRecip(&x,&w); TASSERT(fabsf((w.v[0])-(0.028571f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(0.111111f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(0.125000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fRecipLocal() { SST_Vec3f x; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 14.000000f; x.v[1] = 36.000000f; x.v[2] = 24.000000f; /* [ 14. 36. 24.] [ 0.26726124 0.16666667 0.20412414] */ SST_Math_Vec3fRecipLocal(&x); /* for accuracy */ TASSERT(fabsf((x.v[0])-(0.071429f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(0.027778f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(0.041667f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fNormalize() { SST_Vec3f x; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = -13.000000f; x.v[1] = -17.000000f; x.v[2] = 10.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [-13. -17. 10.] [-0.55033386 -0.71966738 0.42333373] */ SST_Math_Vec3fNormalize(&x,&w); TASSERT(fabsf((w.v[0])-(-0.550334f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(-0.719667f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(0.423334f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fNormalizeLocal() { SST_Vec3f x; /* 3 vector */ /* Resetting test vectors */ x.v[0] = -14.000000f; x.v[1] = -19.000000f; x.v[2] = 12.000000f; /* [-14. -19. 12.] [-0.52877271 -0.71762013 0.45323375] */ SST_Math_Vec3fNormalizeLocal(&x); /* for accuracy */ TASSERT(fabsf((x.v[0])-(-0.528773f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(-0.717620f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(0.453234f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fProject() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = -5.000000f; x.v[1] = 19.000000f; x.v[2] = -6.000000f; y.v[0] = 2.000000f; y.v[1] = 14.000000f; y.v[2] = -10.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [ -5. 19. -6.] [ 2. 14. -10.] [ 2.10666656 14.74666595 -10.53333282] */ SST_Math_Vec3fProject(&x,&y,&w); TASSERT(fabsf((w.v[0])-(2.106667f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(14.746666f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(-10.533333f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fProjectLocal() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 7.000000f; x.v[1] = 17.000000f; x.v[2] = 13.000000f; y.v[0] = -2.000000f; y.v[1] = 12.000000f; y.v[2] = 12.000000f; /* [ 7. 17. 13.] [ -2. 12. 12.] [ -2.36986303 14.2191782 14.2191782 ] */ SST_Math_Vec3fProjectLocal(&x,&y); /* for accuracy */ TASSERT(fabsf((x.v[0])-(-2.369863f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(14.219178f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(14.219178f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fCross() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ SST_Vec3f w; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 12.000000f; x.v[1] = -16.000000f; x.v[2] = 12.000000f; y.v[0] = 9.000000f; y.v[1] = 6.000000f; y.v[2] = 16.000000f; w.v[0] = 0.000000f; w.v[1] = 0.000000f; w.v[2] = 0.000000f; /* [ 12. -16. 12.] [ 9. 6. 16.] [-328. -84. 216.] */ SST_Math_Vec3fCross(&x,&y,&w); TASSERT(fabsf((w.v[0])-(-328.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(-84.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(216.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fCrossLocal() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ /* Resetting test vectors */ x.v[0] = 6.000000f; x.v[1] = 10.000000f; x.v[2] = 13.000000f; y.v[0] = 17.000000f; y.v[1] = 19.000000f; y.v[2] = -15.000000f; /* [ 6. 10. 13.] [ 17. 19. -15.] [-397. 311. -56.] */ SST_Math_Vec3fCrossLocal(&x,&y); /* for accuracy */ TASSERT(fabsf((x.v[0])-(-397.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(311.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(-56.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fRotateAbout() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ SST_Vec3f w; /* 3 vector */ x.v[0] = 1.000000f; x.v[1] = 0.000000f; x.v[2] = 0.000000f; y.v[0] = 0.000000f; y.v[1] = 0.000000f; y.v[2] = 1.000000f; /* [ 1. 0. 0.] [ 0. 0. 1.] [ 0. 1. 0.] */ SST_Math_Vec3fRotateAbout(&x,&y,1.570796f,&w); TASSERT(fabsf((w.v[0])-(0.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((w.v[1])-(1.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((w.v[2])-(0.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fRotateAboutLocal() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ x.v[0] = 1.000000f; x.v[1] = 0.000000f; x.v[2] = 0.000000f; y.v[0] = 0.000000f; y.v[1] = 0.000000f; y.v[2] = 1.000000f; /* [ 1. 0. 0.] [ 0. 0. 1.] [ 0. 1. 0.] */ SST_Math_Vec3fRotateAboutLocal(&x,&y,1.570796f); TASSERT(fabsf((x.v[0])-(0.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabsf((x.v[1])-(1.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabsf((x.v[2])-(0.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fMagnitude() { SST_Vec3f x; /* 3 vector */ float a; /* scalar */ /* Resetting test vectors */ x.v[0] = -19.000000f; x.v[1] = 13.000000f; x.v[2] = -17.000000f; /* [-19. 13. -17.] 28.6182 */ a = SST_Math_Vec3fMagnitude(&x); TASSERT(fabsf((a)-(28.618176f)) <=100*FLT_EPSILON /* yes this is bad */,"Magnitude failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fMagnitudeSquared() { SST_Vec3f x; /* 3 vector */ float a; /* scalar */ /* Resetting test vectors */ x.v[0] = -10.000000f; x.v[1] = -20.000000f; x.v[2] = 19.000000f; /* [-10. -20. 19.] 861.0 */ a = SST_Math_Vec3fMagnitudeSquared(&x); TASSERT(fabsf((a)-(861.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"MagnitudeSquared failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec3fDot() { SST_Vec3f x; /* 3 vector */ SST_Vec3f y; /* 3 vector */ float a; /* scalar */ /* Resetting test vectors */ x.v[0] = -14.000000f; x.v[1] = 4.000000f; x.v[2] = 10.000000f; y.v[0] = 19.000000f; y.v[1] = -15.000000f; y.v[2] = 0.000000f; /* [-14. 4. 10.] -326.0 */ a = SST_Math_Vec3fDot(&x,&y); TASSERT(fabsf((a)-(-326.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Dot failed!"); return ZTEST_SUCCESS; } /******************************************************************************/