750 lines
27 KiB
C++
750 lines
27 KiB
C++
/*
|
|
AUTOMATICALLY GENERATED FILE - DO NOT EDIT!
|
|
Please change MatrixNxN.py and re-run it
|
|
*/
|
|
/* Generated with ./VectorN.py n = 2, TYPE = double */
|
|
|
|
#include "ZUnitTest.hpp"
|
|
#include <float.h>
|
|
#include <math.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <SST/SST_Vec2.h>
|
|
|
|
|
|
|
|
|
|
static const char* testSST_Math_Vec2dAdd();
|
|
static const char* testSST_Math_Vec2dAddLocal();
|
|
static const char* testSST_Math_Vec2dSubtract();
|
|
static const char* testSST_Math_Vec2dSubtractLocal();
|
|
static const char* testSST_Math_Vec2dMultiply();
|
|
static const char* testSST_Math_Vec2dMultiplyLocal();
|
|
static const char* testSST_Math_Vec2dScale();
|
|
static const char* testSST_Math_Vec2dScaleLocal();
|
|
static const char* testSST_Math_Vec2dDivide();
|
|
static const char* testSST_Math_Vec2dDivideLocal();
|
|
static const char* testSST_Math_Vec2dAbs();
|
|
static const char* testSST_Math_Vec2dAbsLocal();
|
|
static const char* testSST_Math_Vec2dNegate();
|
|
static const char* testSST_Math_Vec2dNegateLocal();
|
|
static const char* testSST_Math_Vec2dBias();
|
|
static const char* testSST_Math_Vec2dBiasLocal();
|
|
static const char* testSST_Math_Vec2dRecip();
|
|
static const char* testSST_Math_Vec2dRecipLocal();
|
|
static const char* testSST_Math_Vec2dRecipSqrt();
|
|
static const char* testSST_Math_Vec2dRecipSqrtLocal();
|
|
static const char* testSST_Math_Vec2dSqrt();
|
|
static const char* testSST_Math_Vec2dSqrtLocal();
|
|
static const char* testSST_Math_Vec2dSqrt();
|
|
static const char* testSST_Math_Vec2dSqrtLocal();
|
|
static const char* testSST_Math_Vec2dCross();
|
|
static const char* testSST_Math_Vec2dCrossLocal();
|
|
static const char* testSST_Math_Vec2dProject();
|
|
static const char* testSST_Math_Vec2dProjectLocal();
|
|
static const char* testSST_Math_Vec2dMagnitude();
|
|
static const char* testSST_Math_Vec2dNormalize();
|
|
static const char* testSST_Math_Vec2dNormalizeLocal();
|
|
static const char* testSST_Math_Vec2dMagnitudeSquared();
|
|
static const char* testSST_Math_Vec2dDot();
|
|
// List of unit tests
|
|
ZUnitTest SST_Math_Vec2dUnitTests[] =
|
|
{
|
|
{ "testSST_Math_Vec2dAdd " , testSST_Math_Vec2dAdd },
|
|
{ "testSST_Math_Vec2dAddLocal " , testSST_Math_Vec2dAddLocal },
|
|
{ "testSST_Math_Vec2dSubtract " , testSST_Math_Vec2dSubtract },
|
|
{ "testSST_Math_Vec2dSubtractLocal " , testSST_Math_Vec2dSubtractLocal },
|
|
{ "testSST_Math_Vec2dMultiply " , testSST_Math_Vec2dMultiply },
|
|
{ "testSST_Math_Vec2dMultiplyLocal " , testSST_Math_Vec2dMultiplyLocal },
|
|
{ "testSST_Math_Vec2dScale " , testSST_Math_Vec2dScale },
|
|
{ "testSST_Math_Vec2dScaleLocal " , testSST_Math_Vec2dScaleLocal },
|
|
{ "testSST_Math_Vec2dDivide " , testSST_Math_Vec2dDivide },
|
|
{ "testSST_Math_Vec2dDivideLocal " , testSST_Math_Vec2dDivideLocal },
|
|
{ "testSST_Math_Vec2dAbs " , testSST_Math_Vec2dAbs },
|
|
{ "testSST_Math_Vec2dAbsLocal " , testSST_Math_Vec2dAbsLocal },
|
|
{ "testSST_Math_Vec2dNegate " , testSST_Math_Vec2dNegate },
|
|
{ "testSST_Math_Vec2dNegateLocal " , testSST_Math_Vec2dNegateLocal },
|
|
{ "testSST_Math_Vec2dBias " , testSST_Math_Vec2dBias },
|
|
{ "testSST_Math_Vec2dBiasLocal " , testSST_Math_Vec2dBiasLocal },
|
|
{ "testSST_Math_Vec2dRecip " , testSST_Math_Vec2dRecip },
|
|
{ "testSST_Math_Vec2dRecipLocal " , testSST_Math_Vec2dRecipLocal },
|
|
{ "testSST_Math_Vec2dRecipSqrt " , testSST_Math_Vec2dRecipSqrt },
|
|
{ "testSST_Math_Vec2dRecipSqrtLocal " , testSST_Math_Vec2dRecipSqrtLocal },
|
|
{ "testSST_Math_Vec2dSqrt " , testSST_Math_Vec2dSqrt },
|
|
{ "testSST_Math_Vec2dSqrtLocal " , testSST_Math_Vec2dSqrtLocal },
|
|
{ "testSST_Math_Vec2dSqrt " , testSST_Math_Vec2dSqrt },
|
|
{ "testSST_Math_Vec2dSqrtLocal " , testSST_Math_Vec2dSqrtLocal },
|
|
{ "testSST_Math_Vec2dMagnitude " , testSST_Math_Vec2dMagnitude },
|
|
{ "testSST_Math_Vec2dNormalize " , testSST_Math_Vec2dNormalize },
|
|
{ "testSST_Math_Vec2dNormalizeLocal " , testSST_Math_Vec2dNormalizeLocal },
|
|
{ "testSST_Math_Vec2dCross " , testSST_Math_Vec2dCross },
|
|
{ "testSST_Math_Vec2dCrossLocal " , testSST_Math_Vec2dCrossLocal },
|
|
{ "testSST_Math_Vec2dProject " , testSST_Math_Vec2dProject },
|
|
{ "testSST_Math_Vec2dProjectLocal " , testSST_Math_Vec2dProjectLocal },
|
|
{ "testSST_Math_Vec2dMagnitudeSquared " , testSST_Math_Vec2dMagnitudeSquared },
|
|
{ "testSST_Math_Vec2dDot " , testSST_Math_Vec2dDot }
|
|
};
|
|
DECLARE_ZTESTBLOCK(SST_Math_Vec2d)
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dAdd()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 14.0000000000000000;
|
|
x.v[1] = -14.0000000000000000;
|
|
y.v[0] = -2.0000000000000000;
|
|
y.v[1] = -20.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[ 14. -14.]
|
|
[ -2. -20.]
|
|
[ 12. -34.]
|
|
*/
|
|
SST_Math_Vec2dAdd(&x,&y,&w);
|
|
TASSERT(fabs((w.v[0])-( 12.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( -34.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dAddLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 10.0000000000000000;
|
|
x.v[1] = 2.0000000000000000;
|
|
y.v[0] = 3.0000000000000000;
|
|
y.v[1] = -11.0000000000000000;
|
|
/*
|
|
[ 10. 2.]
|
|
[ 3. -11.]
|
|
[ 13. -9.]
|
|
*/
|
|
SST_Math_Vec2dAddLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 13.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( -9.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dSubtract()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 13.0000000000000000;
|
|
x.v[1] = 11.0000000000000000;
|
|
y.v[0] = 15.0000000000000000;
|
|
y.v[1] = -11.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[ 13. 11.]
|
|
[ 15. -11.]
|
|
[ -2. 22.]
|
|
*/
|
|
SST_Math_Vec2dSubtract(&x,&y,&w);
|
|
TASSERT(fabs((w.v[0])-( -2.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( 22.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dSubtractLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -4.0000000000000000;
|
|
x.v[1] = 19.0000000000000000;
|
|
y.v[0] = -19.0000000000000000;
|
|
y.v[1] = -12.0000000000000000;
|
|
/*
|
|
[ -4. 19.]
|
|
[-19. -12.]
|
|
[ 15. 31.]
|
|
*/
|
|
SST_Math_Vec2dSubtractLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 15.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( 31.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dMultiply()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 12.0000000000000000;
|
|
x.v[1] = 18.0000000000000000;
|
|
y.v[0] = -1.0000000000000000;
|
|
y.v[1] = 7.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[ 12. 18.]
|
|
[-1. 7.]
|
|
[ -12. 126.]
|
|
*/
|
|
SST_Math_Vec2dMultiply(&x,&y,&w);
|
|
TASSERT(fabs((w.v[0])-( -12.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( 126.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dMultiplyLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -16.0000000000000000;
|
|
x.v[1] = 2.0000000000000000;
|
|
y.v[0] = -10.0000000000000000;
|
|
y.v[1] = 9.0000000000000000;
|
|
/*
|
|
[-16. 2.]
|
|
[-10. 9.]
|
|
[ 160. 18.]
|
|
*/
|
|
SST_Math_Vec2dMultiplyLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 160.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( 18.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dDivide()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 6.0000000000000000;
|
|
x.v[1] = 6.0000000000000000;
|
|
y.v[0] = 33.0000000000000000;
|
|
y.v[1] = 26.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[ 6. 6.]
|
|
[ 33. 26.]
|
|
[ 0.18181818 0.23076923]
|
|
*/
|
|
SST_Math_Vec2dDivide(&x,&y,&w);
|
|
TASSERT(fabs((w.v[0])-( 0.1818181818181818)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( 0.2307692307692308)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dDivideLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 8.0000000000000000;
|
|
x.v[1] = 24.0000000000000000;
|
|
y.v[0] = 32.0000000000000000;
|
|
y.v[1] = 24.0000000000000000;
|
|
/*
|
|
[ 8. 24.]
|
|
[ 32. 24.]
|
|
[ 0.25 1. ]
|
|
*/
|
|
SST_Math_Vec2dDivideLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 0.2500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( 1.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dScale()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
double a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 16.0000000000000000;
|
|
x.v[1] = -15.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
a = 2.0000000000000000;
|
|
/*
|
|
[ 16. -15.]
|
|
[ 32. -30.]
|
|
*/
|
|
SST_Math_Vec2dScale(&x,a,&w);
|
|
TASSERT(fabs((w.v[0])-( 32.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( -30.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dScaleLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
double a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 3.0000000000000000;
|
|
x.v[1] = -7.0000000000000000;
|
|
a = 2.0000000000000000;
|
|
/*
|
|
[ 3. -7.]
|
|
[ 6. -14.]
|
|
*/
|
|
SST_Math_Vec2dScaleLocal(&x,a); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 6.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( -14.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dAbs()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -19.0000000000000000;
|
|
x.v[1] = -1.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[-19. -1.]
|
|
[ 19. 1.]
|
|
*/
|
|
SST_Math_Vec2dAbs(&x,&w);
|
|
TASSERT(fabs((w.v[0])-( 19.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( 1.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dAbsLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -17.0000000000000000;
|
|
x.v[1] = 16.0000000000000000;
|
|
/*
|
|
[-17. 16.]
|
|
[ 17. 16.]
|
|
*/
|
|
SST_Math_Vec2dAbsLocal(&x); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 17.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( 16.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dBias()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
double a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -11.0000000000000000;
|
|
x.v[1] = 0.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
a = -19.0000000000000000;
|
|
/*
|
|
[-11. 0.]
|
|
[-22. 0.]
|
|
*/
|
|
SST_Math_Vec2dBias(&x,a,&w);
|
|
TASSERT(fabs((w.v[0])-( -30.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( -19.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dBiasLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
double a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -18.0000000000000000;
|
|
x.v[1] = -3.0000000000000000;
|
|
a = -4.0000000000000000;
|
|
/*
|
|
[-18. -3.]
|
|
[-36. -6.]
|
|
*/
|
|
SST_Math_Vec2dBiasLocal(&x,a); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( -22.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( -7.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dNegate()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -4.0000000000000000;
|
|
x.v[1] = -19.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[ -4. -19.]
|
|
[ 4. 19.]
|
|
*/
|
|
SST_Math_Vec2dNegate(&x,&w);
|
|
TASSERT(fabs((w.v[0])-( 4.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( 19.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dNegateLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -7.0000000000000000;
|
|
x.v[1] = -2.0000000000000000;
|
|
/*
|
|
[-7. -2.]
|
|
[ 7. 2.]
|
|
*/
|
|
SST_Math_Vec2dNegateLocal(&x); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 7.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( 2.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dSqrt()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 14.0000000000000000;
|
|
x.v[1] = 32.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[ 14. 32.]
|
|
[ 3.74165739 5.65685425]
|
|
*/
|
|
SST_Math_Vec2dSqrt(&x,&w);
|
|
TASSERT(fabs((w.v[0])-( 3.7416573867739413)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( 5.6568542494923806)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dSqrtLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 34.0000000000000000;
|
|
x.v[1] = 15.0000000000000000;
|
|
/*
|
|
[ 34. 15.]
|
|
[ 5.83095189 3.87298335]
|
|
*/
|
|
SST_Math_Vec2dSqrtLocal(&x); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 5.8309518948453007)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( 3.8729833462074170)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dRecipSqrt()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 11.0000000000000000;
|
|
x.v[1] = 33.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[ 11. 33.]
|
|
[ 0.30151134 0.17407766]
|
|
*/
|
|
SST_Math_Vec2dRecipSqrt(&x,&w);
|
|
TASSERT(fabs((w.v[0])-( 0.3015113445777636)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( 0.1740776559556979)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dRecipSqrtLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 2.0000000000000000;
|
|
x.v[1] = 15.0000000000000000;
|
|
/*
|
|
[ 2. 15.]
|
|
[ 0.70710678 0.25819889]
|
|
*/
|
|
SST_Math_Vec2dRecipSqrtLocal(&x); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 0.7071067811865475)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( 0.2581988897471611)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dRecip()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 35.0000000000000000;
|
|
x.v[1] = 2.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[ 35. 2.]
|
|
[ 0.02857143 0.5 ]
|
|
*/
|
|
SST_Math_Vec2dRecip(&x,&w);
|
|
TASSERT(fabs((w.v[0])-( 0.0285714285714286)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( 0.5000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dRecipLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 8.0000000000000000;
|
|
x.v[1] = 19.0000000000000000;
|
|
/*
|
|
[ 8. 19.]
|
|
[ 0.35355339 0.22941573]
|
|
*/
|
|
SST_Math_Vec2dRecipLocal(&x); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 0.1250000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( 0.0526315789473684)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dNormalize()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -16.0000000000000000;
|
|
x.v[1] = -6.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[-16. -6.]
|
|
[-0.93632918 -0.35112344]
|
|
*/
|
|
SST_Math_Vec2dNormalize(&x,&w);
|
|
TASSERT(fabs((w.v[0])-( -0.9363291775690445)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( -0.3511234415883917)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dNormalizeLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -8.0000000000000000;
|
|
x.v[1] = -18.0000000000000000;
|
|
/*
|
|
[ -8. -18.]
|
|
[-0.40613847 -0.91381155]
|
|
*/
|
|
SST_Math_Vec2dNormalizeLocal(&x); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( -0.4061384660534477)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( -0.9138115486202573)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dProject()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 9.0000000000000000;
|
|
x.v[1] = 0.0000000000000000;
|
|
y.v[0] = -14.0000000000000000;
|
|
y.v[1] = 4.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[ 9. 0.]
|
|
[-14. 4.]
|
|
[ 8.32075472 -2.37735849]
|
|
*/
|
|
SST_Math_Vec2dProject(&x,&y,&w);
|
|
TASSERT(fabs((w.v[0])-( 8.3207547169811313)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( -2.3773584905660377)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dProjectLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -20.0000000000000000;
|
|
x.v[1] = -6.0000000000000000;
|
|
y.v[0] = -9.0000000000000000;
|
|
y.v[1] = -8.0000000000000000;
|
|
/*
|
|
[-20. -6.]
|
|
[-9. -8.]
|
|
[-14.15172414 -12.57931034]
|
|
*/
|
|
SST_Math_Vec2dProjectLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( -14.1517241379310352)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( -12.5793103448275865)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dCross()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
SST_Vec2d w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -4.0000000000000000;
|
|
x.v[1] = 5.0000000000000000;
|
|
y.v[0] = 5.0000000000000000;
|
|
y.v[1] = 16.0000000000000000;
|
|
w.v[0] = 0.0000000000000000;
|
|
w.v[1] = 0.0000000000000000;
|
|
/*
|
|
[-4. 5.]
|
|
[ 5. 16.]
|
|
-89.0
|
|
*/
|
|
SST_Math_Vec2dCross(&x,&y,&w);
|
|
TASSERT(fabs((w.v[0])-( -89.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((w.v[1])-( -89.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dCrossLocal()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -13.0000000000000000;
|
|
x.v[1] = 0.0000000000000000;
|
|
y.v[0] = -8.0000000000000000;
|
|
y.v[1] = -5.0000000000000000;
|
|
/*
|
|
[-13. 0.]
|
|
[-8. -5.]
|
|
65.0
|
|
*/
|
|
SST_Math_Vec2dCrossLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabs((x.v[0])-( 65.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabs((x.v[1])-( 65.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dMagnitude()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
double a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 1.0000000000000000;
|
|
x.v[1] = 19.0000000000000000;
|
|
/*
|
|
[ 1. 19.]
|
|
19.0262975904
|
|
*/
|
|
a = SST_Math_Vec2dMagnitude(&x);
|
|
TASSERT(fabs((a)-( 19.0262975904404463)) <=100*DBL_EPSILON /* yes this is bad */,"Magnitude failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dMagnitudeSquared()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
double a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 2.0000000000000000;
|
|
x.v[1] = 9.0000000000000000;
|
|
/*
|
|
[ 2. 9.]
|
|
85.0
|
|
*/
|
|
a = SST_Math_Vec2dMagnitudeSquared(&x);
|
|
TASSERT(fabs((a)-( 85.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"MagnitudeSquared failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2dDot()
|
|
{
|
|
SST_Vec2d x; /* 2 vector */
|
|
SST_Vec2d y; /* 2 vector */
|
|
double a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 16.0000000000000000;
|
|
x.v[1] = 14.0000000000000000;
|
|
y.v[0] = -17.0000000000000000;
|
|
y.v[1] = -16.0000000000000000;
|
|
/*
|
|
[ 16. 14.]
|
|
-496.0
|
|
*/
|
|
a = SST_Math_Vec2dDot(&x,&y);
|
|
TASSERT(fabs((a)-( -496.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Dot failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|