diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-03-17 20:13:35 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-03-17 21:57:16 +0300 |
commit | 6ceb84c21724c6c3278abb1bfc27813f7a8f4036 (patch) | |
tree | 4db5f6ec65865295ef3c61a3cf28cbe84242ca38 /source/blender/blenlib/intern/math_vector_inline.c | |
parent | 948bc66a004d15324236f516a9b05001a39e1610 (diff) |
BLI math vec: add 'abs' functions to get absolute values of a vector.
Unseful when handling e.g. scale, sometimes.
Diffstat (limited to 'source/blender/blenlib/intern/math_vector_inline.c')
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 6b6a3113e0b..89ae23fd448 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -611,6 +611,48 @@ MINLINE void negate_v3_short(short r[3]) r[2] = (short)-r[2]; } +MINLINE void abs_v2(float r[2]) +{ + r[0] = fabs(r[0]); + r[1] = fabs(r[1]); +} + +MINLINE void abs_v2_v2(float r[2], const float a[2]) +{ + r[0] = fabs(a[0]); + r[1] = fabs(a[1]); +} + +MINLINE void abs_v3(float r[3]) +{ + r[0] = fabs(r[0]); + r[1] = fabs(r[1]); + r[2] = fabs(r[2]); +} + +MINLINE void abs_v3_v3(float r[3], const float a[3]) +{ + r[0] = fabs(a[0]); + r[1] = fabs(a[1]); + r[2] = fabs(a[2]); +} + +MINLINE void abs_v4(float r[4]) +{ + r[0] = fabs(r[0]); + r[1] = fabs(r[1]); + r[2] = fabs(r[2]); + r[3] = fabs(r[3]); +} + +MINLINE void abs_v4_v4(float r[4], const float a[4]) +{ + r[0] = fabs(a[0]); + r[1] = fabs(a[1]); + r[2] = fabs(a[2]); + r[3] = fabs(a[3]); +} + MINLINE float dot_v2v2(const float a[2], const float b[2]) { return a[0] * b[0] + a[1] * b[1]; |