Added some equvalency tests for the other math objects
* ==, != are defined for matrix, quat, euler.
This commit is contained in:
@@ -41,6 +41,36 @@
|
||||
|
||||
#include "constant.h"
|
||||
|
||||
//---------------------- EXPP_FloatsAreEqual -------------------------
|
||||
//Floating point comparisons
|
||||
//floatStep = number of representable floats allowable in between
|
||||
// float A and float B to be considered equal.
|
||||
int EXPP_FloatsAreEqual(float A, float B, int floatSteps)
|
||||
{
|
||||
int a, b, delta;
|
||||
assert(floatSteps > 0 && floatSteps < (4 * 1024 * 1024));
|
||||
a = *(int*)&A;
|
||||
if (a < 0)
|
||||
a = 0x80000000 - a;
|
||||
b = *(int*)&B;
|
||||
if (b < 0)
|
||||
b = 0x80000000 - b;
|
||||
delta = abs(a - b);
|
||||
if (delta <= floatSteps)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
//---------------------- EXPP_VectorsAreEqual -------------------------
|
||||
//Builds on EXPP_FloatsAreEqual to test vectors
|
||||
int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps){
|
||||
|
||||
int x;
|
||||
for (x=0; x< size; x++){
|
||||
if (EXPP_FloatsAreEqual(vecA[x], vecB[x], floatSteps) == 0)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
//---------------------- EXPP_GetModuleConstant -------------------------
|
||||
//Helper function for returning a module constant
|
||||
PyObject *EXPP_GetModuleConstant(char *module, char *constant)
|
||||
|
||||
Reference in New Issue
Block a user