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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-01-14 06:47:24 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-14 06:47:24 +0400
commitaa986c3f3d5cee39d218cadba2c41d218e9ef21b (patch)
tree7757f6b3680a2ea042b4e09fd80f0834abd69aa2 /source
parent20cea92db13ce3927fbf29b7bae57a74db0d46b5 (diff)
Correct bad mistake in own recent to commit to angle calculation
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/intern/math_vector.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 6d3c74abc66..367166578ae 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -292,39 +292,35 @@ float angle_signed_v2v2(const float v1[2], const float v2[2])
float angle_normalized_v3v3(const float v1[3], const float v2[3])
{
- const float len_sq = dot_v3v3(v1, v2);
-
/* double check they are normalized */
BLI_ASSERT_UNIT_V3(v1);
BLI_ASSERT_UNIT_V3(v2);
/* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */
- if (len_sq >= 0.0f) {
- return 2.0f * saasin(sqrtf(len_sq) / 2.0f);
+ if (dot_v3v3(v1, v2) >= 0.0f) {
+ return 2.0f * saasin(len_v3v3(v1, v2) / 2.0f);
}
else {
- float vec[3];
- negate_v3_v3(vec, v2);
- return (float)M_PI - 2.0f * saasin(len_v3v3(vec, v1) / 2.0f);
+ float v2_n[3];
+ negate_v3_v3(v2_n, v2);
+ return (float)M_PI - 2.0f * saasin(len_v3v3(v1, v2_n) / 2.0f);
}
}
float angle_normalized_v2v2(const float v1[2], const float v2[2])
{
- const float len_sq = dot_v2v2(v1, v2);
-
/* double check they are normalized */
BLI_ASSERT_UNIT_V2(v1);
BLI_ASSERT_UNIT_V2(v2);
/* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */
- if (len_sq >= 0.0f) {
- return 2.0f * saasin(sqrtf(len_sq) / 2.0f);
+ if (dot_v2v2(v1, v2) >= 0.0f) {
+ return 2.0f * saasin(len_v2v2(v1, v2) / 2.0f);
}
else {
- float vec[2];
- negate_v2_v2(vec, v2);
- return (float)M_PI - 2.0f * saasin(len_v2v2(vec, v1) / 2.0f);
+ float v2_n[2];
+ negate_v2_v2(v2_n, v2);
+ return (float)M_PI - 2.0f * saasin(len_v2v2(v1, v2_n) / 2.0f);
}
}