-Another fix for mathutils.anglebetweenvecs()
* test dot before clamping
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user