Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/mathutils/mathutils_Quaternion.c
| Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value) | ||||
| mat3_to_quat(self->quat, rmat); | mat3_to_quat(self->quat, rmat); | ||||
| mul_qt_fl(self->quat, length); /* maintain length after rotating */ | mul_qt_fl(self->quat, length); /* maintain length after rotating */ | ||||
| (void)BaseMath_WriteCallback(self); | (void)BaseMath_WriteCallback(self); | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(Quaternion_make_compatible_doc, | |||||
| ".. method:: make_compatible(other)\n" | |||||
| "\n" | |||||
| " Make this quaternion compatible with another,\n" | |||||
| " so interpolating between them works as intended.\n"); | |||||
| static PyObject *Quaternion_make_compatible(QuaternionObject *self, PyObject *value) | |||||
| { | |||||
| float quat[QUAT_SIZE]; | |||||
| float tquat[QUAT_SIZE]; | |||||
| if (BaseMath_ReadCallback_ForWrite(self) == -1) { | |||||
| return NULL; | |||||
| } | |||||
| if (mathutils_array_parse(tquat, | |||||
| QUAT_SIZE, | |||||
| QUAT_SIZE, | |||||
| value, | |||||
| "Quaternion.make_compatible(other), invalid 'other' arg") == -1) { | |||||
| return NULL; | |||||
| } | |||||
| /* Can only operate on unit length quaternions. */ | |||||
| const float quat_len = normalize_qt_qt(quat, self->quat); | |||||
| quat_to_compatible_quat(self->quat, quat, tquat); | |||||
| mul_qt_fl(self->quat, quat_len); | |||||
| (void)BaseMath_WriteCallback(self); | |||||
| Py_RETURN_NONE; | |||||
| } | |||||
| /* ----------------------------Quaternion.normalize()---------------- */ | /* ----------------------------Quaternion.normalize()---------------- */ | ||||
| /* Normalize the quaternion. This may change the angle as well as the | /* Normalize the quaternion. This may change the angle as well as the | ||||
| * rotation axis, as all of (w, x, y, z) are scaled. */ | * rotation axis, as all of (w, x, y, z) are scaled. */ | ||||
| PyDoc_STRVAR(Quaternion_normalize_doc, | PyDoc_STRVAR(Quaternion_normalize_doc, | ||||
| ".. function:: normalize()\n" | ".. function:: normalize()\n" | ||||
| "\n" | "\n" | ||||
| " Normalize the quaternion.\n"); | " Normalize the quaternion.\n"); | ||||
| static PyObject *Quaternion_normalize(QuaternionObject *self) | static PyObject *Quaternion_normalize(QuaternionObject *self) | ||||
| ▲ Show 20 Lines • Show All 1,010 Lines • ▼ Show 20 Lines | static struct PyMethodDef Quaternion_methods[] = { | ||||
| {"cross", (PyCFunction)Quaternion_cross, METH_O, Quaternion_cross_doc}, | {"cross", (PyCFunction)Quaternion_cross, METH_O, Quaternion_cross_doc}, | ||||
| {"dot", (PyCFunction)Quaternion_dot, METH_O, Quaternion_dot_doc}, | {"dot", (PyCFunction)Quaternion_dot, METH_O, Quaternion_dot_doc}, | ||||
| {"rotation_difference", | {"rotation_difference", | ||||
| (PyCFunction)Quaternion_rotation_difference, | (PyCFunction)Quaternion_rotation_difference, | ||||
| METH_O, | METH_O, | ||||
| Quaternion_rotation_difference_doc}, | Quaternion_rotation_difference_doc}, | ||||
| {"slerp", (PyCFunction)Quaternion_slerp, METH_VARARGS, Quaternion_slerp_doc}, | {"slerp", (PyCFunction)Quaternion_slerp, METH_VARARGS, Quaternion_slerp_doc}, | ||||
| {"rotate", (PyCFunction)Quaternion_rotate, METH_O, Quaternion_rotate_doc}, | {"rotate", (PyCFunction)Quaternion_rotate, METH_O, Quaternion_rotate_doc}, | ||||
| {"make_compatible", | |||||
| (PyCFunction)Quaternion_make_compatible, | |||||
| METH_O, | |||||
| Quaternion_make_compatible_doc}, | |||||
| /* base-math methods */ | /* base-math methods */ | ||||
| {"freeze", (PyCFunction)BaseMathObject_freeze, METH_NOARGS, BaseMathObject_freeze_doc}, | {"freeze", (PyCFunction)BaseMathObject_freeze, METH_NOARGS, BaseMathObject_freeze_doc}, | ||||
| {"copy", (PyCFunction)Quaternion_copy, METH_NOARGS, Quaternion_copy_doc}, | {"copy", (PyCFunction)Quaternion_copy, METH_NOARGS, Quaternion_copy_doc}, | ||||
| {"__copy__", (PyCFunction)Quaternion_copy, METH_NOARGS, Quaternion_copy_doc}, | {"__copy__", (PyCFunction)Quaternion_copy, METH_NOARGS, Quaternion_copy_doc}, | ||||
| {"__deepcopy__", (PyCFunction)Quaternion_deepcopy, METH_VARARGS, Quaternion_copy_doc}, | {"__deepcopy__", (PyCFunction)Quaternion_deepcopy, METH_VARARGS, Quaternion_copy_doc}, | ||||
| {NULL, NULL, 0, NULL}, | {NULL, NULL, 0, NULL}, | ||||
| ▲ Show 20 Lines • Show All 204 Lines • Show Last 20 Lines | |||||