diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-09-06 17:09:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-09-06 17:12:43 +0300 |
commit | 6e0fd239e3f9d876956fad53b02ef6c2b6aef7a9 (patch) | |
tree | 2f9b6587b4592ca8055ab1130275afa97792160a /source/blender/blenlib/intern/math_vector.c | |
parent | 2d407fc288bbdf840d81bcc20fcfca60b9d14d4e (diff) |
Math Lib: normalized vector project functions
Diffstat (limited to 'source/blender/blenlib/intern/math_vector.c')
-rw-r--r-- | source/blender/blenlib/intern/math_vector.c | 25 |
1 files changed, 25 insertions, 0 deletions
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. |