Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Gilbert <ascotan@gmail.com>2005-11-22 20:59:49 +0300
committerJoseph Gilbert <ascotan@gmail.com>2005-11-22 20:59:49 +0300
commitb63e26e109ba8c651ea20f553e3ca8e0604fc73f (patch)
tree677cb0099c10224c50606d64b7d750b23ca4a8e7 /source/blender/python/api2_2x/gen_utils.c
parent6c619b235cb640a350694ec0902ce19c9f9fad0b (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.c30
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)