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:
authorJoseph Gilbert <ascotan@gmail.com>2005-10-10 23:50:53 +0400
committerJoseph Gilbert <ascotan@gmail.com>2005-10-10 23:50:53 +0400
commit28e585b05813288f742c342a00312b97caae3ff6 (patch)
treeb0a060fbc51768c032bc9df9f8187b79464f854b /source/blender/python/api2_2x/Mathutils.c
parent48f69653c8f5a193acc3a8adbba70a429dd9b41e (diff)
-Another fix for mathutils.anglebetweenvecs()
* test dot before clamping
Diffstat (limited to 'source/blender/python/api2_2x/Mathutils.c')
-rw-r--r--source/blender/python/api2_2x/Mathutils.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/python/api2_2x/Mathutils.c b/source/blender/python/api2_2x/Mathutils.c
index d2ab6d96f6b..966fabc7ff5 100644
--- a/source/blender/python/api2_2x/Mathutils.c
+++ b/source/blender/python/api2_2x/Mathutils.c
@@ -485,10 +485,12 @@ PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args)
dot += vec1->vec[x] * vec2->vec[x];
}
dot /= (sqrt(test_v1) * sqrt(test_v2));
- CLAMP(dot,-1.0f,1.0f);
+
+ if (dot < -1.0f || dot > 1.0f)
+ CLAMP(dot,-1.0f,1.0f);
angleRads = (double)acos(dot);
- return PyFloat_FromDouble(angleRads * (180 / Py_PI));
+ return PyFloat_FromDouble(angleRads * (180/ Py_PI));
AttributeError1:
return EXPP_ReturnPyObjError(PyExc_AttributeError,