[Bf-blender-cvs] [6e0fd239e3f] master: Math Lib: normalized vector project functions

Campbell Barton noreply at git.blender.org
Wed Sep 6 16:04:43 CEST 2017


Commit: 6e0fd239e3f9d876956fad53b02ef6c2b6aef7a9
Author: Campbell Barton
Date:   Thu Sep 7 00:09:56 2017 +1000
Branches: master
https://developer.blender.org/rB6e0fd239e3f9d876956fad53b02ef6c2b6aef7a9

Math Lib: normalized vector project functions

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

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

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

diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 43f414f376a..4fdb33926a2 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -299,6 +299,8 @@ void angle_poly_v3(float *angles, const float *verts[3], int len);
 
 void project_v2_v2v2(float out[2], const float p[2], const float v_proj[2]);
 void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3]);
+void project_v2_v2v2_normalized(float out[2], const float p[2], const float v_proj[2]);
+void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3]);
 void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3]);
 void project_plane_v2_v2v2(float out[2], const float p[2], const float v_plane[2]);
 void project_plane_normalized_v3_v3v3(float out[3], const float p[3], const float v_plane[3]);
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index c6e9b8229ba..5f44c93e169 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -652,6 +652,31 @@ void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
 }
 
 /**
+ * Project \a p onto a unit length \a v_proj
+ */
+void project_v2_v2v2_normalized(float out[2], const float p[2], const float v_proj[2])
+{
+	BLI_ASSERT_UNIT_V2(v_proj);
+	const float mul = dot_v2v2(p, v_proj);
+
+	out[0] = mul * v_proj[0];
+	out[1] = mul * v_proj[1];
+}
+
+/**
+ * Project \a p onto a unit length \a v_proj
+ */
+void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
+{
+	BLI_ASSERT_UNIT_V3(v_proj);
+	const float mul = dot_v3v3(p, v_proj);
+
+	out[0] = mul * v_proj[0];
+	out[1] = mul * v_proj[1];
+	out[2] = mul * v_proj[2];
+}
+
+/**
  * In this case plane is a 3D vector only (no 4th component).
  *
  * Projecting will make \a c a copy of \a v orthogonal to \a v_plane.



More information about the Bf-blender-cvs mailing list