Blender V4.3
mathutils_Euler.cc File Reference
#include <algorithm>
#include <Python.h>
#include "mathutils.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_utildefines.hh"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "BLI_dynstr.h"

Go to the source code of this file.

Macros

#define EULER_SIZE   3
 
#define MAKE_ID3(a, b, c)   (((a) << 24) | ((b) << 16) | ((c) << 8))
 

Functions

Utilities
static const char * euler_order_str (EulerObject *self)
 
short euler_order_from_string (const char *str, const char *error_prefix)
 
static PyObject * Euler_to_tuple_ex (EulerObject *self, int ndigits)
 
Euler Type: <tt>__new__</tt> / <tt>mathutils.Euler()</tt>
static PyObject * Euler_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 
Euler Methods
 PyDoc_STRVAR (Euler_to_quaternion_doc, ".. method:: to_quaternion()\n" "\n" " Return a quaternion representation of the euler.\n" "\n" " :return: Quaternion representation of the euler.\n" " :rtype: :class:`Quaternion`\n")
 
static PyObject * Euler_to_quaternion (EulerObject *self)
 
 PyDoc_STRVAR (Euler_to_matrix_doc, ".. method:: to_matrix()\n" "\n" " Return a matrix representation of the euler.\n" "\n" " :return: A 3x3 rotation matrix representation of the euler.\n" " :rtype: :class:`Matrix`\n")
 
static PyObject * Euler_to_matrix (EulerObject *self)
 
 PyDoc_STRVAR (Euler_zero_doc, ".. method:: zero()\n" "\n" " Set all values to zero.\n")
 
static PyObject * Euler_zero (EulerObject *self)
 
 PyDoc_STRVAR (Euler_rotate_axis_doc, ".. method:: rotate_axis(axis, angle)\n" "\n" " Rotates the euler a certain amount and returning a unique euler rotation\n" " (no 720 degree pitches).\n" "\n" " :arg axis: single character in ['X, 'Y', 'Z'].\n" " :type axis: str\n" " :arg angle: angle in radians.\n" " :type angle: float\n")
 
static PyObject * Euler_rotate_axis (EulerObject *self, PyObject *args)
 
 PyDoc_STRVAR (Euler_rotate_doc, ".. method:: rotate(other)\n" "\n" " Rotates the euler by another mathutils value.\n" "\n" " :arg other: rotation component of mathutils value\n" " :type other: :class:`Euler` | :class:`Quaternion` | :class:`Matrix`\n")
 
static PyObject * Euler_rotate (EulerObject *self, PyObject *value)
 
 PyDoc_STRVAR (Euler_make_compatible_doc, ".. method:: make_compatible(other)\n" "\n" " Make this euler compatible with another,\n" " so interpolating between them works as intended.\n" "\n" " .. note:: the rotation order is not taken into account for this function.\n")
 
static PyObject * Euler_make_compatible (EulerObject *self, PyObject *value)
 
 PyDoc_STRVAR (Euler_copy_doc, ".. function:: copy()\n" "\n" " Returns a copy of this euler.\n" "\n" " :return: A copy of the euler.\n" " :rtype: :class:`Euler`\n" "\n" " .. note:: use this to get a copy of a wrapped euler with\n" " no reference to the original data.\n")
 
static PyObject * Euler_copy (EulerObject *self)
 
static PyObject * Euler_deepcopy (EulerObject *self, PyObject *args)
 
Euler Type: <tt>__repr__</tt> & <tt>__str__</tt>
static PyObject * Euler_repr (EulerObject *self)
 
static PyObject * Euler_str (EulerObject *self)
 
Euler Type: Rich Compare
static PyObject * Euler_richcmpr (PyObject *a, PyObject *b, int op)
 
Euler Type: Hash (<tt>__hash__</tt>)
static Py_hash_t Euler_hash (EulerObject *self)
 
Euler Type: Sequence Protocol
static Py_ssize_t Euler_len (EulerObject *)
 
static PyObject * Euler_item (EulerObject *self, Py_ssize_t i)
 
static int Euler_ass_item (EulerObject *self, Py_ssize_t i, PyObject *value)
 
static PyObject * Euler_slice (EulerObject *self, int begin, int end)
 
static int Euler_ass_slice (EulerObject *self, int begin, int end, PyObject *seq)
 
static PyObject * Euler_subscript (EulerObject *self, PyObject *item)
 
static int Euler_ass_subscript (EulerObject *self, PyObject *item, PyObject *value)
 
Euler Type: Get/Set Item Implementation
 PyDoc_STRVAR (Euler_axis_doc, "Euler axis angle in radians.\n" "\n" ":type: float")
 
static PyObject * Euler_axis_get (EulerObject *self, void *type)
 
static int Euler_axis_set (EulerObject *self, PyObject *value, void *type)
 
 PyDoc_STRVAR (Euler_order_doc, "Euler rotation order.\n" "\n" ":type: str in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']")
 
static PyObject * Euler_order_get (EulerObject *self, void *)
 
static int Euler_order_set (EulerObject *self, PyObject *value, void *)
 
Euler Type: C/API Constructors
PyObject * Euler_CreatePyObject (const float eul[3], const short order, PyTypeObject *base_type)
 
PyObject * Euler_CreatePyObject_wrap (float eul[3], const short order, PyTypeObject *base_type)
 
PyObject * Euler_CreatePyObject_cb (PyObject *cb_user, const short order, uchar cb_type, uchar cb_subtype)
 

Variables

Euler Type: Sequence & Mapping Protocol Declarations
static PySequenceMethods Euler_SeqMethods
 
static PyMappingMethods Euler_AsMapping
 
Euler Type: Get/Set Item Definitions
static PyGetSetDef Euler_getseters []
 
Euler Type: Method Definitions
static PyMethodDef Euler_methods []
 

Euler Type: Python Object Definition

PyTypeObject euler_Type
 
 PyDoc_STRVAR (euler_doc, ".. class:: Euler(angles, order='XYZ')\n" "\n" " This object gives access to Eulers in Blender.\n" "\n" " .. seealso:: `Euler angles <https://en.wikipedia.org/wiki/Euler_angles>`__ on Wikipedia.\n" "\n" " :arg angles: (X, Y, Z) angles in radians.\n" " :type angles: Sequence[float]\n" " :arg order: Optional order of the angles, a permutation of ``XYZ``.\n" " :type order: str\n")
 

Macro Definition Documentation

◆ EULER_SIZE

◆ MAKE_ID3

#define MAKE_ID3 ( a,
b,
c )   (((a) << 24) | ((b) << 16) | ((c) << 8))

Referenced by euler_order_from_string().

Function Documentation

◆ Euler_ass_item()

static int Euler_ass_item ( EulerObject * self,
Py_ssize_t i,
PyObject * value )
static

Sequence accessor (set): object[i] = x.

Definition at line 485 of file mathutils_Euler.cc.

References BaseMath_Prepare_ForWrite, BaseMath_WriteIndexCallback, EULER_SIZE, and self.

Referenced by Euler_ass_subscript(), and Euler_axis_set().

◆ Euler_ass_slice()

static int Euler_ass_slice ( EulerObject * self,
int begin,
int end,
PyObject * seq )
static

Sequence slice accessor (set): object[i:j] = x.

Definition at line 547 of file mathutils_Euler.cc.

References BaseMath_ReadCallback_ForWrite, BaseMath_WriteCallback, CLAMP, EULER_SIZE, mathutils_array_parse(), self, and size().

Referenced by Euler_ass_subscript().

◆ Euler_ass_subscript()

static int Euler_ass_subscript ( EulerObject * self,
PyObject * item,
PyObject * value )
static

Sequence generic subscript (set): object[...] = x.

Definition at line 622 of file mathutils_Euler.cc.

References Euler_ass_item(), Euler_ass_slice(), EULER_SIZE, and self.

◆ Euler_axis_get()

static PyObject * Euler_axis_get ( EulerObject * self,
void * type )
static

Definition at line 693 of file mathutils_Euler.cc.

References Euler_item(), POINTER_AS_INT, and self.

◆ Euler_axis_set()

static int Euler_axis_set ( EulerObject * self,
PyObject * value,
void * type )
static

Definition at line 698 of file mathutils_Euler.cc.

References Euler_ass_item(), POINTER_AS_INT, and self.

◆ Euler_copy()

static PyObject * Euler_copy ( EulerObject * self)
static

Definition at line 325 of file mathutils_Euler.cc.

References BaseMath_ReadCallback, Euler_CreatePyObject(), and self.

Referenced by Euler_deepcopy().

◆ Euler_CreatePyObject()

PyObject * Euler_CreatePyObject ( const float eul[3],
const short order,
PyTypeObject * base_type )

◆ Euler_CreatePyObject_cb()

PyObject * Euler_CreatePyObject_cb ( PyObject * cb_user,
const short order,
uchar cb_type,
uchar cb_subtype )

Definition at line 949 of file mathutils_Euler.cc.

References BLI_assert, Euler_CreatePyObject(), and self.

Referenced by pyrna_math_object_from_array().

◆ Euler_CreatePyObject_wrap()

PyObject * Euler_CreatePyObject_wrap ( float eul[3],
const short order,
PyTypeObject * base_type )

◆ Euler_deepcopy()

static PyObject * Euler_deepcopy ( EulerObject * self,
PyObject * args )
static

Definition at line 333 of file mathutils_Euler.cc.

References Euler_copy(), PyC_CheckArgs_DeepCopy(), and self.

◆ Euler_hash()

static Py_hash_t Euler_hash ( EulerObject * self)
static

◆ Euler_item()

static PyObject * Euler_item ( EulerObject * self,
Py_ssize_t i )
static

Sequence accessor (get): x = object[i].

Definition at line 464 of file mathutils_Euler.cc.

References BaseMath_ReadIndexCallback, EULER_SIZE, and self.

Referenced by Euler_axis_get(), and Euler_subscript().

◆ Euler_len()

static Py_ssize_t Euler_len ( EulerObject * )
static

Sequence length: len(object).

Definition at line 458 of file mathutils_Euler.cc.

References EULER_SIZE.

◆ Euler_make_compatible()

static PyObject * Euler_make_compatible ( EulerObject * self,
PyObject * value )
static

◆ Euler_new()

static PyObject * Euler_new ( PyTypeObject * type,
PyObject * args,
PyObject * kwds )
static

◆ euler_order_from_string()

short euler_order_from_string ( const char * str,
const char * error_prefix )

◆ Euler_order_get()

static PyObject * Euler_order_get ( EulerObject * self,
void *  )
static

Definition at line 711 of file mathutils_Euler.cc.

References BaseMath_ReadCallback, euler_order_str(), and self.

◆ Euler_order_set()

static int Euler_order_set ( EulerObject * self,
PyObject * value,
void *  )
static

◆ euler_order_str()

static const char * euler_order_str ( EulerObject * self)
static

Internal use, assume read callback is done.

Definition at line 33 of file mathutils_Euler.cc.

References EULER_ORDER_XYZ, and self.

Referenced by Euler_order_get(), Euler_repr(), and Euler_str().

◆ Euler_repr()

static PyObject * Euler_repr ( EulerObject * self)
static

◆ Euler_richcmpr()

static PyObject * Euler_richcmpr ( PyObject * a,
PyObject * b,
int op )
static

◆ Euler_rotate()

static PyObject * Euler_rotate ( EulerObject * self,
PyObject * value )
static

◆ Euler_rotate_axis()

static PyObject * Euler_rotate_axis ( EulerObject * self,
PyObject * args )
static

◆ Euler_slice()

static PyObject * Euler_slice ( EulerObject * self,
int begin,
int end )
static

Sequence slice accessor (get): x = object[i:j].

Definition at line 522 of file mathutils_Euler.cc.

References BaseMath_ReadCallback, CLAMP, count, EULER_SIZE, and self.

Referenced by Euler_subscript().

◆ Euler_str()

static PyObject * Euler_str ( EulerObject * self)
static

◆ Euler_subscript()

static PyObject * Euler_subscript ( EulerObject * self,
PyObject * item )
static

Sequence generic subscript (get): x = object[...].

Definition at line 585 of file mathutils_Euler.cc.

References Euler_item(), EULER_SIZE, Euler_slice(), and self.

◆ Euler_to_matrix()

static PyObject * Euler_to_matrix ( EulerObject * self)
static

◆ Euler_to_quaternion()

static PyObject * Euler_to_quaternion ( EulerObject * self)
static

◆ Euler_to_tuple_ex()

static PyObject * Euler_to_tuple_ex ( EulerObject * self,
int ndigits )
static
Note
BaseMath_ReadCallback must be called beforehand.

Definition at line 74 of file mathutils_Euler.cc.

References double_round(), EULER_SIZE, ret, and self.

Referenced by Euler_repr().

◆ Euler_zero()

static PyObject * Euler_zero ( EulerObject * self)
static

Definition at line 193 of file mathutils_Euler.cc.

References BaseMath_Prepare_ForWrite, BaseMath_WriteCallback, self, and zero_v3().

◆ PyDoc_STRVAR() [1/10]

PyDoc_STRVAR ( Euler_axis_doc ,
"Euler axis angle in radians.\n" "\n" ":type: float"  )

◆ PyDoc_STRVAR() [2/10]

PyDoc_STRVAR ( Euler_copy_doc ,
".. function:: copy()\n" "\n" " Returns a copy of this euler.\n" "\n" " :return: A copy of the euler.\n" " :rtype: :class:`Euler`\n" "\n" " .. note:: use this to get a copy of a wrapped euler with\n" " no reference to the original data.\n"  )

◆ PyDoc_STRVAR() [3/10]

PyDoc_STRVAR ( euler_doc ,
".. class:: Euler(angles, order='XYZ')\n" "\n" " This object gives access to Eulers in Blender.\n" "\n" " .. seealso:: `Euler angles <https://en.wikipedia.org/wiki/Euler_angles>`__ on Wikipedia.\n" "\n" " :arg angles: (X, Y, Z) angles in radians.\n" " :type angles: Sequence\n" " :arg order: Optional order of the angles[float],
a permutation of ``XYZ``.\n" " :type order:str\n"  )

◆ PyDoc_STRVAR() [4/10]

PyDoc_STRVAR ( Euler_make_compatible_doc ,
".. method:: make_compatible(other)\n" "\n" " Make this euler compatible with another,
\n" " so interpolating between them works as intended.\n" "\n" " .. note::the rotation order is not taken into account for this function.\n"  )

◆ PyDoc_STRVAR() [5/10]

PyDoc_STRVAR ( Euler_order_doc ,
"Euler rotation order.\n" "\n" ":type: str in " [ 'XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX'] )

◆ PyDoc_STRVAR() [6/10]

PyDoc_STRVAR ( Euler_rotate_axis_doc ,
".. method:: rotate_axis(axis, angle)\n" "\n" " Rotates the euler a certain amount and returning a unique euler rotation\n" " (no 720 degree pitches).\n" "\n" " :arg axis: single character in .\n" " :type axis: str\n" " :arg angle: angle in radians.\n" " :type angle: float\n" [ 'X, 'Y', 'Z'] )

◆ PyDoc_STRVAR() [7/10]

PyDoc_STRVAR ( Euler_rotate_doc ,
".. method:: rotate(other)\n" "\n" " Rotates the euler by another mathutils value.\n" "\n" " :arg other: rotation component of mathutils value\n" " :type other: :class:`Euler` | :class:`Quaternion` | :class:`Matrix`\n"  )

◆ PyDoc_STRVAR() [8/10]

PyDoc_STRVAR ( Euler_to_matrix_doc ,
".. method:: to_matrix()\n" "\n" " Return a matrix representation of the euler.\n" "\n" " :return: A 3x3 rotation matrix representation of the euler.\n" " :rtype: :class:`Matrix`\n"  )

◆ PyDoc_STRVAR() [9/10]

PyDoc_STRVAR ( Euler_to_quaternion_doc ,
".. method:: to_quaternion()\n" "\n" " Return a quaternion representation of the euler.\n" "\n" " :return: Quaternion representation of the euler.\n" " :rtype: :class:`Quaternion`\n"  )

◆ PyDoc_STRVAR() [10/10]

PyDoc_STRVAR ( Euler_zero_doc ,
".. method:: zero()\n" "\n" " Set all values to zero.\n"  )

Variable Documentation

◆ Euler_AsMapping

PyMappingMethods Euler_AsMapping
static
Initial value:
= {
(lenfunc)Euler_len,
(binaryfunc)Euler_subscript,
(objobjargproc)Euler_ass_subscript,
}
static PyObject * Euler_subscript(EulerObject *self, PyObject *item)
static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *value)
static Py_ssize_t Euler_len(EulerObject *)

Definition at line 673 of file mathutils_Euler.cc.

◆ Euler_getseters

PyGetSetDef Euler_getseters[]
static
Initial value:
= {
{"x", (getter)Euler_axis_get, (setter)Euler_axis_set, Euler_axis_doc, POINTER_FROM_INT(0)},
{"y", (getter)Euler_axis_get, (setter)Euler_axis_set, Euler_axis_doc, POINTER_FROM_INT(1)},
{"z", (getter)Euler_axis_get, (setter)Euler_axis_set, Euler_axis_doc, POINTER_FROM_INT(2)},
{"order", (getter)Euler_order_get, (setter)Euler_order_set, Euler_order_doc, nullptr},
{"is_wrapped",
(setter) nullptr,
nullptr},
{"is_frozen",
(setter) nullptr,
nullptr},
{"is_valid",
(setter) nullptr,
nullptr},
{"owner",
(setter) nullptr,
nullptr},
{nullptr, nullptr, nullptr, nullptr, nullptr}
}
#define POINTER_FROM_INT(i)
char BaseMathObject_is_valid_doc[]
Definition mathutils.cc:639
char BaseMathObject_is_wrapped_doc[]
Definition mathutils.cc:625
PyObject * BaseMathObject_owner_get(BaseMathObject *self, void *)
Definition mathutils.cc:619
char BaseMathObject_is_frozen_doc[]
Definition mathutils.cc:632
PyObject * BaseMathObject_is_frozen_get(BaseMathObject *self, void *)
Definition mathutils.cc:634
PyObject * BaseMathObject_is_wrapped_get(BaseMathObject *self, void *)
Definition mathutils.cc:627
char BaseMathObject_owner_doc[]
Definition mathutils.cc:618
PyObject * BaseMathObject_is_valid_get(BaseMathObject *self, void *)
Definition mathutils.cc:640
static PyObject * Euler_order_get(EulerObject *self, void *)
static int Euler_axis_set(EulerObject *self, PyObject *value, void *type)
static int Euler_order_set(EulerObject *self, PyObject *value, void *)
static PyObject * Euler_axis_get(EulerObject *self, void *type)

Definition at line 747 of file mathutils_Euler.cc.

◆ Euler_methods

PyMethodDef Euler_methods[]
static
Initial value:
= {
{"zero", (PyCFunction)Euler_zero, METH_NOARGS, Euler_zero_doc},
{"to_matrix", (PyCFunction)Euler_to_matrix, METH_NOARGS, Euler_to_matrix_doc},
{"to_quaternion", (PyCFunction)Euler_to_quaternion, METH_NOARGS, Euler_to_quaternion_doc},
{"rotate_axis", (PyCFunction)Euler_rotate_axis, METH_VARARGS, Euler_rotate_axis_doc},
{"rotate", (PyCFunction)Euler_rotate, METH_O, Euler_rotate_doc},
{"make_compatible", (PyCFunction)Euler_make_compatible, METH_O, Euler_make_compatible_doc},
{"copy", (PyCFunction)Euler_copy, METH_NOARGS, Euler_copy_doc},
{"__copy__", (PyCFunction)Euler_copy, METH_NOARGS, Euler_copy_doc},
{"__deepcopy__", (PyCFunction)Euler_deepcopy, METH_VARARGS, Euler_copy_doc},
{"freeze", (PyCFunction)BaseMathObject_freeze, METH_NOARGS, BaseMathObject_freeze_doc},
{nullptr, nullptr, 0, nullptr},
}
PyObject * BaseMathObject_freeze(BaseMathObject *self)
Definition mathutils.cc:653
char BaseMathObject_freeze_doc[]
Definition mathutils.cc:645
static PyObject * Euler_copy(EulerObject *self)
static PyObject * Euler_zero(EulerObject *self)
static PyObject * Euler_rotate(EulerObject *self, PyObject *value)
static PyObject * Euler_deepcopy(EulerObject *self, PyObject *args)
static PyObject * Euler_make_compatible(EulerObject *self, PyObject *value)
static PyObject * Euler_rotate_axis(EulerObject *self, PyObject *args)
static PyObject * Euler_to_matrix(EulerObject *self)
static PyObject * Euler_to_quaternion(EulerObject *self)

Definition at line 787 of file mathutils_Euler.cc.

◆ Euler_SeqMethods

PySequenceMethods Euler_SeqMethods
static
Initial value:
= {
(lenfunc)Euler_len,
nullptr,
nullptr,
(ssizeargfunc)Euler_item,
nullptr,
(ssizeobjargproc)Euler_ass_item,
nullptr,
nullptr,
nullptr,
nullptr,
}
static PyObject * Euler_item(EulerObject *self, Py_ssize_t i)
static int Euler_ass_item(EulerObject *self, Py_ssize_t i, PyObject *value)

Definition at line 660 of file mathutils_Euler.cc.

◆ euler_Type