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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-07-10 15:32:35 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-07-10 16:02:43 +0300
commit7837f0e8332f3726e0322b0c48b0da4d7c2d5813 (patch)
tree4e0b9d6fb5faa6bacd080484d7ef625566d32699 /source/blender/blenlib/BLI_math_vector.h
parentbbcbd2eed9081e0c1127d32e41592a8dc6b5604b (diff)
BLI_math 'compare' cleanup & enhancements.
This commit: * Adds a 'compare_ff' function for absolute 'almost equal' comparison of floats. * Makes 'compare_vxvx' functions use that new 'compare_ff' one. * Adds a 'compare_ff_relative' function for secured ulp-based relative comparison of floats. * Adds matching 'compare_vxvx_relative' functions. * Adds some basic tests for compare_ff_relative. See https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ Note that we could replace our python/mathutils' EXPP_FloatsAreEqual() by BLI's compare_ff_relative (using a very small absolute max_diff), but these do not have exact same behavior... Left a comment there for now, we can do it later if/when we are sure it won't break anything!
Diffstat (limited to 'source/blender/blenlib/BLI_math_vector.h')
-rw-r--r--source/blender/blenlib/BLI_math_vector.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 9bc1121801e..493c285d251 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -240,14 +240,19 @@ MINLINE bool is_one_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT;
MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT;
MINLINE bool equals_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE bool equals_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT;
+
MINLINE bool compare_v2v2(const float a[2], const float b[2], const float limit) ATTR_WARN_UNUSED_RESULT;
MINLINE bool compare_v3v3(const float a[3], const float b[3], const float limit) ATTR_WARN_UNUSED_RESULT;
+MINLINE bool compare_v4v4(const float a[4], const float b[4], const float limit) ATTR_WARN_UNUSED_RESULT;
+
+MINLINE bool compare_v2v2_relative(const float a[2], const float b[2], const float limit, const int max_ulps) ATTR_WARN_UNUSED_RESULT;
+MINLINE bool compare_v3v3_relative(const float a[3], const float b[3], const float limit, const int max_ulps) ATTR_WARN_UNUSED_RESULT;
+MINLINE bool compare_v4v4_relative(const float a[4], const float b[4], const float limit, const int max_ulps) ATTR_WARN_UNUSED_RESULT;
+
MINLINE bool compare_len_v3v3(const float a[3], const float b[3], const float limit) ATTR_WARN_UNUSED_RESULT;
MINLINE bool compare_len_squared_v3v3(const float a[3], const float b[3], const float limit) ATTR_WARN_UNUSED_RESULT;
-MINLINE bool compare_v4v4(const float a[4], const float b[4], const float limit) ATTR_WARN_UNUSED_RESULT;
-MINLINE bool equals_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT;
-
MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) ATTR_WARN_UNUSED_RESULT;
/********************************** Angles ***********************************/