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>2009-06-26 00:47:41 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-06-26 00:47:41 +0400
commit4b914c7f75faa65a7d2a991b7904c18051d13a13 (patch)
tree35ff731a37f612e491f21ee1b036f3d1679e9a69 /source/blender/python/generic/Mathutils.c
parent47ca543b32e74b67e5f8eb6265cc08f93018b002 (diff)
Made Mathutils use radians rather then degrees. defining USE_MATHUTILS_DEG for testing existing scripts.
Added conversion for BGE Quaternion WXYZ (Blender/C) -> XYZW (Moto C++). BGE Python API now uses WXYZ following mathutils (break script warning).
Diffstat (limited to 'source/blender/python/generic/Mathutils.c')
-rw-r--r--source/blender/python/generic/Mathutils.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/python/generic/Mathutils.c b/source/blender/python/generic/Mathutils.c
index d7330ac46c0..ec94a48ddbd 100644
--- a/source/blender/python/generic/Mathutils.c
+++ b/source/blender/python/generic/Mathutils.c
@@ -275,8 +275,11 @@ static PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args)
angleRads = (double)saacos(dot);
+#ifdef USE_MATHUTILS_DEG
return PyFloat_FromDouble(angleRads * (180/ Py_PI));
-
+#else
+ return PyFloat_FromDouble(angleRads);
+#endif
AttributeError1:
PyErr_SetString(PyExc_AttributeError, "Mathutils.AngleBetweenVecs(): expects (2) VECTOR objects of the same size\n");
return NULL;
@@ -364,12 +367,19 @@ static PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args)
PyErr_SetString(PyExc_TypeError, "Mathutils.RotationMatrix(): expected float int and optional string and vector\n");
return NULL;
}
-
+
+#ifdef USE_MATHUTILS_DEG
/* Clamp to -360:360 */
while (angle<-360.0f)
angle+=360.0;
while (angle>360.0f)
angle-=360.0;
+#else
+ while (angle<-(Py_PI*2))
+ angle+=(Py_PI*2);
+ while (angle>(Py_PI*2))
+ angle-=(Py_PI*2);
+#endif
if(matSize != 2 && matSize != 3 && matSize != 4) {
PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
@@ -399,8 +409,11 @@ static PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args)
return NULL;
}
+#ifdef USE_MATHUTILS_DEG
//convert to radians
angle = angle * (float) (Py_PI / 180);
+#endif
+
if(axis == NULL && matSize == 2) {
//2D rotation matrix
mat[0] = (float) cos (angle);