diff options
author | Joseph Gilbert <ascotan@gmail.com> | 2005-11-22 20:59:49 +0300 |
---|---|---|
committer | Joseph Gilbert <ascotan@gmail.com> | 2005-11-22 20:59:49 +0300 |
commit | b63e26e109ba8c651ea20f553e3ca8e0604fc73f (patch) | |
tree | 677cb0099c10224c50606d64b7d750b23ca4a8e7 /source/blender/python/api2_2x/gen_utils.c | |
parent | 6c619b235cb640a350694ec0902ce19c9f9fad0b (diff) |
Added some equvalency tests for the other math objects
* ==, != are defined for matrix, quat, euler.
Diffstat (limited to 'source/blender/python/api2_2x/gen_utils.c')
-rw-r--r-- | source/blender/python/api2_2x/gen_utils.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c index b88d8e22010..de29e4ba001 100644 --- a/source/blender/python/api2_2x/gen_utils.c +++ b/source/blender/python/api2_2x/gen_utils.c @@ -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) |