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:
authorCampbell Barton <ideasman42@gmail.com>2011-04-02 07:05:49 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-04-02 07:05:49 +0400
commitf1b42a129f0f9299a9e67eb0495131a37464c9cc (patch)
tree99bda9a0c293524a04f0ba4cfd91cc87c378810f /source/blender/python
parent69bd72c3b6aa1fdaab0c1232a6ba1e3e4c9029fa (diff)
add angle wrapping functions: angle_wrap_rad(), angle_wrap_deg().
use with mathutils.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/generic/mathutils_Matrix.c3
-rw-r--r--source/blender/python/generic/mathutils_Quaternion.c4
2 files changed, 3 insertions, 4 deletions
diff --git a/source/blender/python/generic/mathutils_Matrix.c b/source/blender/python/generic/mathutils_Matrix.c
index 936c761bf90..41d9626db16 100644
--- a/source/blender/python/generic/mathutils_Matrix.c
+++ b/source/blender/python/generic/mathutils_Matrix.c
@@ -226,8 +226,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
}
}
- /* clamp angle between -360 and 360 in radians */
- angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2;
+ angle= angle_wrap_rad(angle);
if(matSize != 2 && matSize != 3 && matSize != 4) {
PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): can only return a 2x2 3x3 or 4x4 matrix");
diff --git a/source/blender/python/generic/mathutils_Quaternion.c b/source/blender/python/generic/mathutils_Quaternion.c
index 43d3cbc62b0..be1fa6db035 100644
--- a/source/blender/python/generic/mathutils_Quaternion.c
+++ b/source/blender/python/generic/mathutils_Quaternion.c
@@ -861,7 +861,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
return -1;
}
- angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2;
+ angle= angle_wrap_rad(angle);
/* If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations */
if( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
@@ -955,7 +955,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
case 2:
if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1)
return NULL;
- angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2; /* clamp because of precision issues */
+ angle= angle_wrap_rad(angle); /* clamp because of precision issues */
axis_angle_to_quat(quat, quat, angle);
break;
/* PyArg_ParseTuple assures no more then 2 */