diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-09 14:23:34 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-09 15:03:55 +0300 |
commit | 17941860530693dfce76a4bf3d25e0e29610a20b (patch) | |
tree | 07f4d7a6c42f32537df0ef20c4c876b0667322b9 /source | |
parent | 2e72d756c4909cd77f9313909159e368a26ccc92 (diff) |
BLI_math: add vector's dot_v3v3v3() func, for when you have three points instead of two vectors.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 6885a5aa351..4455e72cf45 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -148,6 +148,7 @@ MINLINE void negate_v3_short(short r[3]); MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT; MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT; +MINLINE float dot_v3v3v3(const float p[3], const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT; MINLINE float dot_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT; MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index da9d5bd3f49..6b6a3113e0b 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -621,6 +621,18 @@ MINLINE float dot_v3v3(const float a[3], const float b[3]) return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } +MINLINE float dot_v3v3v3(const float p[3], const float a[3], const float b[3]) +{ + float vec1[3], vec2[3]; + + sub_v3_v3v3(vec1, a, p); + sub_v3_v3v3(vec2, b, p); + if (is_zero_v3(vec1) || is_zero_v3(vec2)) { + return 0.0f; + } + return dot_v3v3(vec1, vec2); +} + MINLINE float dot_v4v4(const float a[4], const float b[4]) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; |