diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-01-29 12:44:26 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-01-29 12:44:26 +0300 |
commit | 31a1590db0bbfee2f81052b6eaa845f8ed93e96d (patch) | |
tree | f65ef3bc721a599af1821cdbe896687f3bcff179 /source/blender/python/api2_2x/Mathutils.c | |
parent | 24aa536f5492b57d185a5b98d699b965578a3f0a (diff) |
Bugfix: quaternion angle calculation in python used the acos function.
This gives nan if the input is e.g. 1.00000001 due to rounding errors,
better is to use saacos (safe acos) that checks for the range first.
Diffstat (limited to 'source/blender/python/api2_2x/Mathutils.c')
-rw-r--r-- | source/blender/python/api2_2x/Mathutils.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/source/blender/python/api2_2x/Mathutils.c b/source/blender/python/api2_2x/Mathutils.c index cf79b3071f7..65ae46ffccd 100644 --- a/source/blender/python/api2_2x/Mathutils.c +++ b/source/blender/python/api2_2x/Mathutils.c @@ -1,5 +1,5 @@ /* - * $Id: Mathutils.c 11502 2007-08-06 14:27:08Z khughes $ + * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * @@ -500,10 +500,7 @@ PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args) } dot /= (sqrt(test_v1) * sqrt(test_v2)); - if (dot < -1.0f || dot > 1.0f) { - CLAMP(dot,-1.0f,1.0f); - } - angleRads = (double)acos(dot); + angleRads = (double)saacos(dot); return PyFloat_FromDouble(angleRads * (180/ Py_PI)); |