diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-14 10:14:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-14 10:14:15 +0400 |
commit | ee9a00948b950f8361ef280b5f88674721a6698f (patch) | |
tree | f75025f04750f530692baf00cc924bbb57d4f5f2 /source/blender/blenlib/intern/math_vector.c | |
parent | f15c15e992a9836a7295166af275522690ada315 (diff) |
mathutils py api:
Vector.angle_signed(other)
for 2D vectors to get the clockwise angle between them.
in BLI math its called - angle_signed_v2v2()
shorthand for...
atan2f((v1[1] * v2[0]) - (v1[0] * v2[1]), dot_v2v2(v1, v2))
also corrects compile error in last commit.
Diffstat (limited to 'source/blender/blenlib/intern/math_vector.c')
-rw-r--r-- | source/blender/blenlib/intern/math_vector.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 01ba62bc741..39e1a9b31f0 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -174,6 +174,12 @@ float angle_v2v2(const float v1[2], const float v2[2]) return angle_normalized_v2v2(vec1, vec2); } +float angle_signed_v2v2(const float v1[2], const float v2[2]) +{ + const float perp_dot = (v1[1] * v2[0]) - (v1[0] * v2[1]); + return atan2f(perp_dot, dot_v2v2(v1, v2)); +} + float angle_normalized_v3v3(const float v1[3], const float v2[3]) { /* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */ |