diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-11-30 08:57:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-11-30 08:57:16 +0400 |
commit | 5910531318c02f0f223ce608dcbe0a6e3232828a (patch) | |
tree | 93e619abd11f4849fa78de37a1c7093f16b91755 /source/blender/blenlib/intern/math_geom_inline.c | |
parent | 8aff45d8f671e7eb2f404c8f194e06d88c5147c9 (diff) |
Math Library: add functions cross_poly_v2, cross_tri_v2
also added utility macro for removing elements in the middle of an array
Diffstat (limited to 'source/blender/blenlib/intern/math_geom_inline.c')
-rw-r--r-- | source/blender/blenlib/intern/math_geom_inline.c | 17 |
1 files changed, 17 insertions, 0 deletions
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 <string.h> +/********************************** 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]) |