Commit: 17941860530693dfce76a4bf3d25e0e29610a20b
Author: Bastien Montagne
Date:   Fri Jan 9 12:23:34 2015 +0100
Branches: master
https://developer.blender.org/rB17941860530693dfce76a4bf3d25e0e29610a20b

BLI_math: add vector's dot_v3v3v3() func, for when you have three points 
instead of two vectors.

===================================================================

M       source/blender/blenlib/BLI_math_vector.h
M       source/blender/blenlib/intern/math_vector_inline.c

===================================================================

diff --git a/source/blender/blenlib/BLI_math_vector.h 
b/source/blender/blenlib/BLI_math_vector.h
index 6885a5a..4455e72 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 da9d5bd..6b6a311 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];

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to