diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-12-09 05:57:18 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-12-09 06:03:38 +0300 |
commit | 1898c1f05cd38ea82f6da2ac3af07bab56537f3b (patch) | |
tree | 72c6f836b80f95864cd8c0fefa544a9c3d9682e4 | |
parent | d7851b87a7f7f471f9b5c6813be5f66a7936b2ff (diff) |
Math Lib: add axis_dominant_v3_ortho_single
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 3 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom_inline.c | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index d804b57ffe1..bf483386752 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -417,7 +417,8 @@ void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3]); MINLINE void axis_dominant_v3(int *r_axis_a, int *r_axis_b, const float axis[3]); MINLINE float axis_dominant_v3_max(int *r_axis_a, int *r_axis_b, const float axis[3]) ATTR_WARN_UNUSED_RESULT; -MINLINE int axis_dominant_v3_single(const float vec[3]); +MINLINE int axis_dominant_v3_single(const float vec[3]); +MINLINE int axis_dominant_v3_ortho_single(const float vec[3]); MINLINE int max_axis_v3(const float vec[3]); MINLINE int min_axis_v3(const float vec[3]); diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 44b17681540..68a2e68db4f 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -199,6 +199,17 @@ MINLINE int axis_dominant_v3_single(const float vec[3]) ((y > z) ? 1 : 2)); } +/* the dominant axis of an orthogonal vector */ +MINLINE int axis_dominant_v3_ortho_single(const float vec[3]) +{ + const float x = fabsf(vec[0]); + const float y = fabsf(vec[1]); + const float z = fabsf(vec[2]); + return ((x < y) ? + ((x < z) ? 0 : 2) : + ((y < z) ? 1 : 2)); +} + MINLINE int max_axis_v3(const float vec[3]) { const float x = vec[0]; |