Commit: aa986c3f3d5cee39d218cadba2c41d218e9ef21b
Author: Campbell Barton
Date: Tue Jan 14 13:47:24 2014 +1100
https://developer.blender.org/rBaa986c3f3d5cee39d218cadba2c41d218e9ef21b
Correct bad mistake in own recent to commit to angle calculation
===================================================================
M source/blender/blenlib/intern/math_vector.c
===================================================================
diff --git a/source/blender/blenlib/intern/math_vector.c
b/source/blender/blenlib/intern/math_vector.c
index 6d3c74a..3671665 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);
}
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs