Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-14 10:14:15 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-14 10:14:15 +0400
commitee9a00948b950f8361ef280b5f88674721a6698f (patch)
treef75025f04750f530692baf00cc924bbb57d4f5f2 /source/blender/blenlib/intern/math_vector.c
parentf15c15e992a9836a7295166af275522690ada315 (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.c6
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 */