Blender V5.3
mathutils_Quaternion.cc File Reference
#include <algorithm>
#include <Python.h>
#include "mathutils.hh"
#include "BLI_math_base_safe.hh"
#include "BLI_math_matrix_c.hh"
#include "BLI_math_rotation_c.hh"
#include "BLI_math_vector_c.hh"
#include "BLI_utildefines.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_utildefines.hh"
#include "BLI_dynstr.hh"

Go to the source code of this file.

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define QUAT_SIZE   4

Functions

static void blender::quat__axis_angle_sanitize (float axis[3], float *angle)
Utilities
static PyObject * blender::quat__apply_to_copy (PyObject *(*quat_func)(QuaternionObject *), QuaternionObject *self)
static PyObject * blender::Quaternion_to_tuple_ext (QuaternionObject *self, int ndigits)
Quaternion Methods: Copy/Deep-Copy
static PyObject * blender::Quaternion_copy (QuaternionObject *self)
static PyObject * blender::Quaternion_deepcopy (QuaternionObject *self, PyObject *args)
 blender::PyDoc_STRVAR (Quaternion_copy_doc, ".. method:: copy()\n" "\n" " Returns a copy of this quaternion.\n" "\n" " :return: A copy of the quaternion.\n" " :rtype: :class:`Quaternion`\n" "\n" " .. note:: use this to get a copy of a wrapped quaternion with\n" " no reference to the original data.\n")
Quaternion Type: <tt>__new__</tt> / <tt>mathutils.Quaternion()</tt>
static PyObject * blender::Quaternion_vectorcall (PyObject *type, PyObject *const *args, const size_t nargsf, PyObject *kwnames)
static PyObject * blender::Quaternion_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
Quaternion Methods: To Euler
 blender::PyDoc_STRVAR (Quaternion_to_euler_doc, ".. method:: to_euler(order='XYZ', euler_compat=None, /)\n" "\n" " Return Euler representation of the quaternion.\n" "\n" " :param order: Rotation order.\n" " :type order: Literal['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']\n" " :param euler_compat: Optional euler argument the new euler will be made\n" " compatible with (no axis flipping between them).\n" " Useful for converting a series of quaternions to animation curves.\n" " :type euler_compat: :class:`Euler` | None\n" " :return: Euler representation of the quaternion.\n" " :rtype: :class:`Euler`\n")
static PyObject * blender::Quaternion_to_euler (QuaternionObject *self, PyObject *args)
Quaternion Methods: To Matrix
 blender::PyDoc_STRVAR (Quaternion_to_matrix_doc, ".. method:: to_matrix()\n" "\n" " Return a matrix representation of the quaternion.\n" "\n" " :return: A 3x3 rotation matrix representation of the quaternion.\n" " :rtype: :class:`Matrix`\n")
static PyObject * blender::Quaternion_to_matrix (QuaternionObject *self)
Quaternion Methods: To Axis/Angle
 blender::PyDoc_STRVAR (Quaternion_to_axis_angle_doc, ".. method:: to_axis_angle()\n" "\n" " Return the axis, angle representation of the quaternion.\n" "\n" " :return: Axis, angle.\n" " :rtype: tuple[:class:`Vector`, float]\n")
static PyObject * blender::Quaternion_to_axis_angle (QuaternionObject *self)
Quaternion Methods: To Swing/Twist
 blender::PyDoc_STRVAR (Quaternion_to_swing_twist_doc, ".. method:: to_swing_twist(axis, /)\n" "\n" " Split the rotation into a swing quaternion with the specified\n" " axis fixed at zero, and the remaining twist rotation angle.\n" "\n" " :param axis: Twist axis as a string.\n" " :type axis: Literal['X', 'Y', 'Z']\n" " :return: Swing, twist angle.\n" " :rtype: tuple[:class:`Quaternion`, float]\n")
static PyObject * blender::Quaternion_to_swing_twist (QuaternionObject *self, PyObject *axis_arg)
Quaternion Methods: To Exponential Map
 blender::PyDoc_STRVAR (Quaternion_to_exponential_map_doc, ".. method:: to_exponential_map()\n" "\n" " Return the exponential map representation of the quaternion.\n" "\n" " This representation consists of the rotation axis multiplied by the rotation angle.\n" " Such a representation is useful for interpolation between multiple orientations.\n" "\n" " :return: 3D exponential map.\n" " :rtype: :class:`Vector`\n" "\n" " To convert back to a quaternion, pass it to the :class:`Quaternion` constructor.\n")
static PyObject * blender::Quaternion_to_exponential_map (QuaternionObject *self)
Quaternion Methods: Cross Product
 blender::PyDoc_STRVAR (Quaternion_cross_doc, ".. method:: cross(other, /)\n" "\n" " Return the cross product of this quaternion and another.\n" "\n" " :param other: The other quaternion to perform the cross product with.\n" " :type other: :class:`Quaternion`\n" " :return: The cross product.\n" " :rtype: :class:`Quaternion`\n")
static PyObject * blender::Quaternion_cross (QuaternionObject *self, PyObject *value)
Quaternion Methods: Dot Product
 blender::PyDoc_STRVAR (Quaternion_dot_doc, ".. method:: dot(other, /)\n" "\n" " Return the dot product of this quaternion and another.\n" "\n" " :param other: The other quaternion to perform the dot product with.\n" " :type other: :class:`Quaternion`\n" " :return: The dot product.\n" " :rtype: float\n")
static PyObject * blender::Quaternion_dot (QuaternionObject *self, PyObject *value)
Quaternion Methods: Rotation Difference
 blender::PyDoc_STRVAR (Quaternion_rotation_difference_doc, ".. method:: rotation_difference(other, /)\n" "\n" " Returns a quaternion representing the rotational difference.\n" "\n" " :param other: second quaternion.\n" " :type other: :class:`Quaternion`\n" " :return: the rotational difference between the two quat rotations.\n" " :rtype: :class:`Quaternion`\n")
static PyObject * blender::Quaternion_rotation_difference (QuaternionObject *self, PyObject *value)
Quaternion Methods: Spherical Interpolation (slerp)
 blender::PyDoc_STRVAR (Quaternion_slerp_doc, ".. method:: slerp(other, factor, /)\n" "\n" " Returns the interpolation of two quaternions.\n" "\n" " :param other: value to interpolate with.\n" " :type other: :class:`Quaternion`\n" " :param factor: The interpolation value in [0.0, 1.0].\n" " :type factor: float\n" " :return: The interpolated rotation.\n" " :rtype: :class:`Quaternion`\n")
static PyObject * blender::Quaternion_slerp (QuaternionObject *self, PyObject *args)
Quaternion Methods: Rotate
 blender::PyDoc_STRVAR (Quaternion_rotate_doc, ".. method:: rotate(other, /)\n" "\n" " Rotates the quaternion by another mathutils value.\n" "\n" " :param other: rotation component of mathutils value\n" " :type other: :class:`Euler` | :class:`Quaternion` | :class:`Matrix`\n")
static PyObject * blender::Quaternion_rotate (QuaternionObject *self, PyObject *value)
 blender::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" "\n" " :param other: The reference quaternion to make this one compatible with.\n" " :type other: :class:`Quaternion`\n")
static PyObject * blender::Quaternion_make_compatible (QuaternionObject *self, PyObject *value)
Quaternion Methods: Normalize

Normalize the quaternion. This may change the angle as well as the rotation axis, as all of (w, x, y, z) are scaled.

 blender::PyDoc_STRVAR (Quaternion_normalize_doc, ".. method:: normalize()\n" "\n" " Normalize the quaternion.\n")
static PyObject * blender::Quaternion_normalize (QuaternionObject *self)
 blender::PyDoc_STRVAR (Quaternion_normalized_doc, ".. method:: normalized()\n" "\n" " Return a new normalized quaternion.\n" "\n" " :return: a normalized copy.\n" " :rtype: :class:`Quaternion`\n")
static PyObject * blender::Quaternion_normalized (QuaternionObject *self)
Quaternion Methods: Invert

Invert the quaternion, representing the inverse rotation.

 blender::PyDoc_STRVAR (Quaternion_invert_doc, ".. method:: invert()\n" "\n" " Set the quaternion to its inverse.\n")
static PyObject * blender::Quaternion_invert (QuaternionObject *self)
 blender::PyDoc_STRVAR (Quaternion_inverted_doc, ".. method:: inverted()\n" "\n" " Return a new, inverted quaternion.\n" "\n" " :return: the inverted value.\n" " :rtype: :class:`Quaternion`\n")
static PyObject * blender::Quaternion_inverted (QuaternionObject *self)
Quaternion Methods: Set Identity
 blender::PyDoc_STRVAR (Quaternion_identity_doc, ".. method:: identity()\n" "\n" " Set the quaternion to an identity quaternion.\n")
static PyObject * blender::Quaternion_identity (QuaternionObject *self)
Quaternion Methods: Negate
 blender::PyDoc_STRVAR (Quaternion_negate_doc, ".. method:: negate()\n" "\n" " Set the quaternion to its negative.\n")
static PyObject * blender::Quaternion_negate (QuaternionObject *self)
Quaternion Methods: Conjugate
 blender::PyDoc_STRVAR (Quaternion_conjugate_doc, ".. method:: conjugate()\n" "\n" " Set the quaternion to its conjugate (negate x, y, z).\n")
static PyObject * blender::Quaternion_conjugate (QuaternionObject *self)
 blender::PyDoc_STRVAR (Quaternion_conjugated_doc, ".. method:: conjugated()\n" "\n" " Return a new conjugated quaternion.\n" "\n" " :return: a new quaternion.\n" " :rtype: :class:`Quaternion`\n")
static PyObject * blender::Quaternion_conjugated (QuaternionObject *self)
Quaternion Type: <tt>__repr__</tt> & <tt>__str__</tt>
static PyObject * blender::Quaternion_repr (QuaternionObject *self)
static PyObject * blender::Quaternion_str (QuaternionObject *self)
Quaternion Type: Rich Compare
static PyObject * blender::Quaternion_richcmpr (PyObject *a, PyObject *b, int op)
Quaternion Type: Hash (<tt>__hash__</tt>)
static Py_hash_t blender::Quaternion_hash (QuaternionObject *self)
Quaternion Type: Sequence & Mapping Protocols Implementation
static Py_ssize_t blender::Quaternion_len (QuaternionObject *)
static PyObject * blender::Quaternion_item (QuaternionObject *self, Py_ssize_t i)
static int blender::Quaternion_ass_item (QuaternionObject *self, Py_ssize_t i, PyObject *ob)
static PyObject * blender::Quaternion_slice (QuaternionObject *self, Py_ssize_t start, Py_ssize_t step, Py_ssize_t slice_length)
static int blender::Quaternion_ass_slice (QuaternionObject *self, Py_ssize_t start, Py_ssize_t step, Py_ssize_t slice_length, PyObject *seq)
static PyObject * blender::Quaternion_subscript (QuaternionObject *self, PyObject *item)
static int blender::Quaternion_ass_subscript (QuaternionObject *self, PyObject *item, PyObject *value)
Quaternion Type: Numeric Protocol Implementation
static PyObject * blender::Quaternion_add (PyObject *q1, PyObject *q2)
static PyObject * blender::Quaternion_sub (PyObject *q1, PyObject *q2)
static PyObject * blender::quat_mul_float (QuaternionObject *quat, const float scalar)
static PyObject * blender::Quaternion_mul (PyObject *q1, PyObject *q2)
static PyObject * blender::Quaternion_imul (PyObject *q1, PyObject *q2)
static PyObject * blender::Quaternion_matmul (PyObject *q1, PyObject *q2)
static PyObject * blender::Quaternion_imatmul (PyObject *q1, PyObject *q2)
static PyObject * blender::Quaternion_neg (QuaternionObject *self)
Quaternion Type: Get/Set Item Implementation
 blender::PyDoc_STRVAR (Quaternion_axis_doc, "Quaternion component value.\n" "\n" ":type: float\n")
static PyObject * blender::Quaternion_axis_get (QuaternionObject *self, void *type)
static int blender::Quaternion_axis_set (QuaternionObject *self, PyObject *value, void *type)
 blender::PyDoc_STRVAR (Quaternion_magnitude_doc, "Size of the quaternion (read-only).\n" "\n" ":type: float\n")
static PyObject * blender::Quaternion_magnitude_get (QuaternionObject *self, void *)
 blender::PyDoc_STRVAR (Quaternion_angle_doc, "Angle of the quaternion.\n" "\n" ":type: float\n")
static PyObject * blender::Quaternion_angle_get (QuaternionObject *self, void *)
static int blender::Quaternion_angle_set (QuaternionObject *self, PyObject *value, void *)
 blender::PyDoc_STRVAR (Quaternion_axis_vector_doc, "Quaternion axis as a vector.\n" "\n" ":type: :class:`Vector`\n")
static PyObject * blender::Quaternion_axis_vector_get (QuaternionObject *self, void *)
static int blender::Quaternion_axis_vector_set (QuaternionObject *self, PyObject *value, void *)
Quaternion Type: C/API Constructors
PyObject * blender::Quaternion_CreatePyObject (const float quat[4], PyTypeObject *base_type)
PyObject * blender::Quaternion_CreatePyObject_wrap (float quat[4], PyTypeObject *base_type)
PyObject * blender::Quaternion_CreatePyObject_cb (PyObject *cb_user, uchar cb_type, uchar cb_subtype)

Variables

Quaternion Type: Protocol Declarations
static PySequenceMethods blender::Quaternion_SeqMethods
static PyMappingMethods blender::Quaternion_AsMapping
static PyNumberMethods blender::Quaternion_NumMethods
Quaternion Type: Get/Set Item Definitions
static PyGetSetDef blender::Quaternion_getseters []
Quaternion Type: Method Definitions
static PyMethodDef blender::Quaternion_methods []

Quaternion Type: Buffer Protocol

static PyBufferProcs blender::Quaternion_as_buffer
static int blender::Quaternion_getbuffer (PyObject *obj, Py_buffer *view, int flags)
static void blender::Quaternion_releasebuffer (PyObject *, Py_buffer *view)

Quaternion Type: Python Object Definition

PyTypeObject blender::quaternion_Type
 blender::PyDoc_STRVAR (quaternion_doc, ".. class:: Quaternion(seq=(1.0, 0.0, 0.0, 0.0), angle=0.0, /)\n" "\n" " This object gives access to Quaternions in Blender.\n" "\n" " :param seq: A (w, x, y, z) quaternion, a 3D exponential map vector,\n" " or a 3D axis vector (when *angle* is also provided).\n" " :type seq: Sequence[float]\n" " :param angle: rotation angle, in radians\n" " :type angle: float\n" "\n" " The constructor takes arguments in various forms:\n" "\n" " (), *no args*\n" " Create an identity quaternion\n" " (*wxyz*)\n" " Create a quaternion from a ``(w, x, y, z)`` vector.\n" " (*exponential_map*)\n" " Create a quaternion from a 3d exponential map vector.\n" "\n" " .. seealso:: :meth:`to_exponential_map`\n" " (*axis, angle*)\n" " Create a quaternion representing a rotation of *angle* radians over *axis*.\n" "\n" " .. seealso:: :meth:`to_axis_angle`\n")

Macro Definition Documentation

◆ QUAT_SIZE