diff options
author | Joseph Gilbert <ascotan@gmail.com> | 2005-10-10 23:50:53 +0400 |
---|---|---|
committer | Joseph Gilbert <ascotan@gmail.com> | 2005-10-10 23:50:53 +0400 |
commit | 28e585b05813288f742c342a00312b97caae3ff6 (patch) | |
tree | b0a060fbc51768c032bc9df9f8187b79464f854b /source/blender/python/api2_2x/Mathutils.c | |
parent | 48f69653c8f5a193acc3a8adbba70a429dd9b41e (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.c | 6 |
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, |