From 5910531318c02f0f223ce608dcbe0a6e3232828a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 30 Nov 2013 15:57:16 +1100 Subject: Math Library: add functions cross_poly_v2, cross_tri_v2 also added utility macro for removing elements in the middle of an array --- source/blender/blenlib/intern/math_geom_inline.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/blender/blenlib/intern/math_geom_inline.c') diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index ac5c0033067..1910b964d78 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -34,6 +34,23 @@ #include +/********************************** Polygons *********************************/ + +MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2]) +{ + return (v1[0] - v2[0]) * (v2[1] - v3[1]) + (v1[1] - v2[1]) * (v3[0] - v2[0]); +} + +MINLINE float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2]) +{ + return 0.5f * ((v1[0] - v2[0]) * (v2[1] - v3[1]) + (v1[1] - v2[1]) * (v3[0] - v2[0])); +} + +MINLINE float area_tri_v2(const float v1[2], const float v2[2], const float v3[2]) +{ + return fabsf(area_tri_signed_v2(v1, v2, v3)); +} + /****************************** Spherical Harmonics **************************/ MINLINE void zero_sh(float r[9]) -- cgit v1.2.3 From 07ceb99213166b678f0a0bac9c35e9897f22e827 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Dec 2013 03:46:27 +1100 Subject: Code Cleanup: use strict flags for math lib, add inline declarations --- source/blender/blenlib/intern/math_geom_inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenlib/intern/math_geom_inline.c') diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 1910b964d78..a5906dbdf6c 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -79,7 +79,7 @@ MINLINE void add_sh_shsh(float r[9], const float a[9], const float b[9]) r[i] = a[i] + b[i]; } -MINLINE float dot_shsh(float a[9], float b[9]) +MINLINE float dot_shsh(const float a[9], const float b[9]) { float r = 0.0f; int i; -- cgit v1.2.3