diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-04-20 02:52:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-04-20 02:53:40 +0300 |
commit | dbf1257b14582d5c6cabbed01ef1bf89860106fd (patch) | |
tree | 257526e39019988ca2f3c34a8fe9e1a2af57e1c5 /source/blender/blenlib/intern/math_vector.c | |
parent | 38442ae2dc7ff9fe656b715e0ac92c465dccc7ee (diff) |
Minor optimization for scanfill
Replace angle with with cosine calculation.
Diffstat (limited to 'source/blender/blenlib/intern/math_vector.c')
-rw-r--r-- | source/blender/blenlib/intern/math_vector.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 8d33e04241a..72a3da265c7 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -397,6 +397,19 @@ float angle_v2v2v2(const float v1[2], const float v2[2], const float v3[2]) return angle_normalized_v2v2(vec1, vec2); } +/* Quicker than full angle computation */ +float cos_v2v2v2(const float p1[2], const float p2[2], const float p3[2]) +{ + float vec1[2], vec2[2]; + + sub_v2_v2v2(vec1, p2, p1); + sub_v2_v2v2(vec2, p2, p3); + normalize_v2(vec1); + normalize_v2(vec2); + + return dot_v2v2(vec1, vec2); +} + /* Return the shortest angle in radians between the 2 vectors */ float angle_v2v2(const float v1[2], const float v2[2]) { |