PyAPI: coerce mathutils values. (vectors, quats, eulers) as proposed here:
http://wiki.blender.org/index.php/Dev:2.5/Source/Python/Mathutils#Coerce_Method_Arguments
This commit is contained in:
@@ -80,8 +80,8 @@
|
||||
|
||||
//-------------------------DOC STRINGS ---------------------------
|
||||
static char M_Mathutils_doc[] =
|
||||
"This module provides access to matrices, eulers, quaternions and vectors.";
|
||||
|
||||
"This module provides access to matrices, eulers, quaternions and vectors."
|
||||
;
|
||||
static int mathutils_array_parse_fast(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
|
||||
{
|
||||
PyObject *value_fast= NULL;
|
||||
|
||||
@@ -88,8 +88,8 @@ static char Color_copy_doc[] =
|
||||
" :return: A copy of the color.\n"
|
||||
" :rtype: :class:`Color`\n"
|
||||
"\n"
|
||||
" .. note:: use this to get a copy of a wrapped color with no reference to the original data.\n";
|
||||
|
||||
" .. note:: use this to get a copy of a wrapped color with no reference to the original data.\n"
|
||||
;
|
||||
static PyObject *Color_copy(ColorObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
@@ -461,8 +461,8 @@ static struct PyMethodDef Color_methods[] = {
|
||||
|
||||
//------------------PY_OBECT DEFINITION--------------------------
|
||||
static char color_doc[] =
|
||||
"This object gives access to Colors in Blender.";
|
||||
|
||||
"This object gives access to Colors in Blender."
|
||||
;
|
||||
PyTypeObject color_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"mathutils.Color", //tp_name
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Contributor(s): Joseph Gilbert
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
@@ -44,7 +44,7 @@
|
||||
static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PyObject *seq= NULL;
|
||||
char *order_str= NULL;
|
||||
const char *order_str= NULL;
|
||||
|
||||
float eul[EULER_SIZE]= {0.0f, 0.0f, 0.0f};
|
||||
short order= EULER_ORDER_XYZ;
|
||||
@@ -114,15 +114,15 @@ static PyObject *Euler_ToTupleExt(EulerObject *self, int ndigits)
|
||||
//-----------------------------METHODS----------------------------
|
||||
//return a quaternion representation of the euler
|
||||
|
||||
static char Euler_ToQuat_doc[] =
|
||||
static char Euler_to_quaternion_doc[] =
|
||||
".. method:: to_quat()\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_ToQuat(EulerObject * self)
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Euler_to_quaternion(EulerObject * self)
|
||||
{
|
||||
float quat[4];
|
||||
|
||||
@@ -136,15 +136,15 @@ static PyObject *Euler_ToQuat(EulerObject * self)
|
||||
}
|
||||
|
||||
//return a matrix representation of the euler
|
||||
static char Euler_ToMatrix_doc[] =
|
||||
static char Euler_to_matrix_doc[] =
|
||||
".. method:: to_matrix()\n"
|
||||
"\n"
|
||||
" Return a matrix representation of the euler.\n"
|
||||
"\n"
|
||||
" :return: A 3x3 roation matrix representation of the euler.\n"
|
||||
" :rtype: :class:`Matrix`\n";
|
||||
|
||||
static PyObject *Euler_ToMatrix(EulerObject * self)
|
||||
" :rtype: :class:`Matrix`\n"
|
||||
;
|
||||
static PyObject *Euler_to_matrix(EulerObject * self)
|
||||
{
|
||||
float mat[9] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
@@ -158,15 +158,15 @@ static PyObject *Euler_ToMatrix(EulerObject * self)
|
||||
}
|
||||
|
||||
//sets the euler to 0,0,0
|
||||
static char Euler_Zero_doc[] =
|
||||
static char Euler_zero_doc[] =
|
||||
".. method:: zero()\n"
|
||||
"\n"
|
||||
" Set all values to zero.\n"
|
||||
"\n"
|
||||
" :return: an instance of itself\n"
|
||||
" :rtype: :class:`Euler`\n";
|
||||
|
||||
static PyObject *Euler_Zero(EulerObject * self)
|
||||
" :rtype: :class:`Euler`\n"
|
||||
;
|
||||
static PyObject *Euler_zero(EulerObject * self)
|
||||
{
|
||||
self->eul[0] = 0.0;
|
||||
self->eul[1] = 0.0;
|
||||
@@ -187,12 +187,12 @@ static char Euler_rotate_axis_doc[] =
|
||||
" :arg angle: angle in radians.\n"
|
||||
" :type angle: float\n"
|
||||
" :return: an instance of itself\n"
|
||||
" :rtype: :class:`Euler`";
|
||||
|
||||
" :rtype: :class:`Euler`"
|
||||
;
|
||||
static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args)
|
||||
{
|
||||
float angle = 0.0f;
|
||||
char *axis;
|
||||
const char *axis;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "sf:rotate", &axis, &angle)){
|
||||
PyErr_SetString(PyExc_TypeError, "euler.rotate(): expected angle (float) and axis (x,y,z)");
|
||||
@@ -214,7 +214,7 @@ static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args)
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
static char Euler_MakeCompatible_doc[] =
|
||||
static char Euler_make_compatible_doc[] =
|
||||
".. method:: make_compatible(other)\n"
|
||||
"\n"
|
||||
" Make this euler compatible with another, so interpolating between them works as intended.\n"
|
||||
@@ -224,24 +224,19 @@ static char Euler_MakeCompatible_doc[] =
|
||||
" :return: an instance of itself.\n"
|
||||
" :rtype: :class:`Euler`\n"
|
||||
"\n"
|
||||
" .. note:: the order of eulers must match or an exception is raised.\n";
|
||||
|
||||
static PyObject *Euler_MakeCompatible(EulerObject * self, EulerObject *value)
|
||||
" .. note:: the rotation order is not taken into account for this function.\n"
|
||||
;
|
||||
static PyObject *Euler_make_compatible(EulerObject * self, PyObject *value)
|
||||
{
|
||||
if(!EulerObject_Check(value)) {
|
||||
PyErr_SetString(PyExc_TypeError, "euler.make_compatible(euler): expected a single euler argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
float teul[EULER_SIZE];
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
if(self->order != value->order) {
|
||||
PyErr_SetString(PyExc_ValueError, "euler.make_compatible(euler): rotation orders don't match");
|
||||
if(mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value, "euler.make_compatible(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
compatible_eul(self->eul, value->eul);
|
||||
compatible_eul(self->eul, teul);
|
||||
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
Py_INCREF(self);
|
||||
@@ -259,8 +254,8 @@ static char Euler_copy_doc[] =
|
||||
" :return: A copy of the euler.\n"
|
||||
" :rtype: :class:`Euler`\n"
|
||||
"\n"
|
||||
" .. note:: use this to get a copy of a wrapped euler with no reference to the original data.\n";
|
||||
|
||||
" .. note:: use this to get a copy of a wrapped euler with no reference to the original data.\n"
|
||||
;
|
||||
static PyObject *Euler_copy(EulerObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
@@ -275,7 +270,7 @@ static PyObject *Euler_copy(EulerObject *self)
|
||||
static PyObject *Euler_repr(EulerObject * self)
|
||||
{
|
||||
PyObject *ret, *tuple;
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
@@ -345,7 +340,7 @@ static int Euler_len(EulerObject *UNUSED(self))
|
||||
static PyObject *Euler_item(EulerObject * self, int i)
|
||||
{
|
||||
if(i<0) i= EULER_SIZE-i;
|
||||
|
||||
|
||||
if(i < 0 || i >= EULER_SIZE) {
|
||||
PyErr_SetString(PyExc_IndexError, "euler[attribute]: array index out of range");
|
||||
return NULL;
|
||||
@@ -369,12 +364,12 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value)
|
||||
}
|
||||
|
||||
if(i<0) i= EULER_SIZE-i;
|
||||
|
||||
|
||||
if(i < 0 || i >= EULER_SIZE){
|
||||
PyErr_SetString(PyExc_IndexError, "euler[attribute] = x: array assignment index out of range");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
self->eul[i] = f;
|
||||
|
||||
if(!BaseMath_WriteIndexCallback(self, i))
|
||||
@@ -543,7 +538,7 @@ static PyObject *Euler_getOrder(EulerObject *self, void *UNUSED(closure))
|
||||
|
||||
static int Euler_setOrder(EulerObject *self, PyObject *value, void *UNUSED(closure))
|
||||
{
|
||||
char *order_str= _PyUnicode_AsString(value);
|
||||
const char *order_str= _PyUnicode_AsString(value);
|
||||
short order= euler_order_from_string(order_str, "euler.order");
|
||||
|
||||
if(order == -1)
|
||||
@@ -571,11 +566,11 @@ static PyGetSetDef Euler_getseters[] = {
|
||||
|
||||
//-----------------------METHOD DEFINITIONS ----------------------
|
||||
static struct PyMethodDef Euler_methods[] = {
|
||||
{"zero", (PyCFunction) Euler_Zero, METH_NOARGS, Euler_Zero_doc},
|
||||
{"to_matrix", (PyCFunction) Euler_ToMatrix, METH_NOARGS, Euler_ToMatrix_doc},
|
||||
{"to_quat", (PyCFunction) Euler_ToQuat, METH_NOARGS, Euler_ToQuat_doc},
|
||||
{"zero", (PyCFunction) Euler_zero, METH_NOARGS, Euler_zero_doc},
|
||||
{"to_matrix", (PyCFunction) Euler_to_matrix, METH_NOARGS, Euler_to_matrix_doc},
|
||||
{"to_quat", (PyCFunction) Euler_to_quaternion, METH_NOARGS, Euler_to_quaternion_doc},
|
||||
{"rotate_axis", (PyCFunction) Euler_rotate_axis, METH_VARARGS, Euler_rotate_axis_doc},
|
||||
{"make_compatible", (PyCFunction) Euler_MakeCompatible, METH_O, Euler_MakeCompatible_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},
|
||||
{NULL, NULL, 0, NULL}
|
||||
@@ -583,8 +578,8 @@ static struct PyMethodDef Euler_methods[] = {
|
||||
|
||||
//------------------PY_OBECT DEFINITION--------------------------
|
||||
static char euler_doc[] =
|
||||
"This object gives access to Eulers in Blender.";
|
||||
|
||||
"This object gives access to Eulers in Blender."
|
||||
;
|
||||
PyTypeObject euler_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"mathutils.Euler", //tp_name
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject *value);
|
||||
static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *value);
|
||||
|
||||
/* matrix vector callbacks */
|
||||
int mathutils_matrix_vector_cb_index= -1;
|
||||
@@ -167,8 +167,8 @@ static char C_Matrix_Rotation_doc[] =
|
||||
|
||||
static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
|
||||
{
|
||||
VectorObject *vec= NULL;
|
||||
char *axis= NULL;
|
||||
PyObject *vec= NULL;
|
||||
const char *axis= NULL;
|
||||
int matSize;
|
||||
double angle; /* use double because of precision problems at high values */
|
||||
float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
@@ -179,7 +179,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(vec && !VectorObject_Check(vec)) {
|
||||
if(vec && PyUnicode_Check(vec)) {
|
||||
axis= _PyUnicode_AsString((PyObject *)vec);
|
||||
if(axis==NULL || axis[0]=='\0' || axis[1]!='\0' || axis[0] < 'X' || axis[0] > 'Z') {
|
||||
PyErr_SetString(PyExc_TypeError, "mathutils.RotationMatrix(): 3rd argument axis value must be a 3D vector or a string in 'X', 'Y', 'Z'");
|
||||
@@ -203,23 +203,18 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
if((matSize == 3 || matSize == 4) && (axis == NULL) && (vec == NULL)) {
|
||||
PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): please choose an axis of rotation for 3d and 4d matrices");
|
||||
PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): axis of rotation for 3d and 4d matrices is required");
|
||||
return NULL;
|
||||
}
|
||||
if(vec) {
|
||||
if(vec->size != 3) {
|
||||
PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): the vector axis must be a 3D vector");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(vec))
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
/* check for valid vector/axis above */
|
||||
if(vec) {
|
||||
axis_angle_to_mat3( (float (*)[3])mat,vec->vec, angle);
|
||||
float tvec[3];
|
||||
|
||||
if (mathutils_array_parse(tvec, 3, 3, vec, "mathutils.RotationMatrix(angle, size, axis), invalid 'axis' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
axis_angle_to_mat3((float (*)[3])mat, tvec, angle);
|
||||
}
|
||||
else if(matSize == 2) {
|
||||
//2D rotation matrix
|
||||
@@ -281,29 +276,16 @@ static char C_Matrix_Translation_doc[] =
|
||||
" :return: An identity matrix with a translation.\n"
|
||||
" :rtype: :class:`Matrix`\n";
|
||||
|
||||
static PyObject *C_Matrix_Translation(PyObject *cls, VectorObject * vec)
|
||||
static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value)
|
||||
{
|
||||
float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
if(!VectorObject_Check(vec)) {
|
||||
PyErr_SetString(PyExc_TypeError, "mathutils.Matrix.Translation(): expected vector");
|
||||
return NULL;
|
||||
}
|
||||
if(vec->size != 3 && vec->size != 4) {
|
||||
PyErr_SetString(PyExc_TypeError, "mathutils.Matrix.Translation(): vector must be 3D or 4D");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(vec))
|
||||
return NULL;
|
||||
|
||||
//create a identity matrix and add translation
|
||||
unit_m4((float(*)[4]) mat);
|
||||
mat[12] = vec->vec[0];
|
||||
mat[13] = vec->vec[1];
|
||||
mat[14] = vec->vec[2];
|
||||
float mat[16], tvec[3];
|
||||
|
||||
if (mathutils_array_parse(tvec, 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1)
|
||||
return NULL;
|
||||
|
||||
/* create a identity matrix and add translation */
|
||||
unit_m4((float(*)[4]) mat);
|
||||
copy_v3_v3(mat + 12, tvec); /* 12, 13, 14 */
|
||||
return newMatrixObject(mat, 4, 4, Py_NEW, (PyTypeObject *)cls);
|
||||
}
|
||||
//----------------------------------mathutils.Matrix.Scale() -------------
|
||||
@@ -339,13 +321,13 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
|
||||
}
|
||||
if(vec) {
|
||||
if(vec->size > 2 && matSize == 2) {
|
||||
PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.Scale(): please use 2D vectors when scaling in 2D");
|
||||
PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.Scale(): 2D vectors when scaling in 2D required");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(vec))
|
||||
return NULL;
|
||||
|
||||
|
||||
}
|
||||
if(vec == NULL) { //scaling along axis
|
||||
if(matSize == 2) {
|
||||
@@ -413,30 +395,20 @@ static char C_Matrix_OrthoProjection_doc[] =
|
||||
" :rtype: :class:`Matrix`\n";
|
||||
static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
|
||||
{
|
||||
VectorObject *vec = NULL;
|
||||
char *plane;
|
||||
PyObject *vec= NULL;
|
||||
const char *plane;
|
||||
int matSize, x;
|
||||
float norm = 0.0f;
|
||||
float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
if(!PyArg_ParseTuple(args, "si|O!:Matrix.OrthoProjection", &plane, &matSize, &vector_Type, &vec)) {
|
||||
|
||||
if(!PyArg_ParseTuple(args, "si|O:Matrix.OrthoProjection", &plane, &matSize, &vec)) {
|
||||
return NULL;
|
||||
}
|
||||
if(matSize != 2 && matSize != 3 && matSize != 4) {
|
||||
PyErr_SetString(PyExc_AttributeError,"mathutils.Matrix.OrthoProjection(): can only return a 2x2 3x3 or 4x4 matrix");
|
||||
return NULL;
|
||||
}
|
||||
if(vec) {
|
||||
if(vec->size > 2 && matSize == 2) {
|
||||
PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.OrthoProjection(): please use 2D vectors when scaling in 2D");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(vec))
|
||||
return NULL;
|
||||
|
||||
}
|
||||
if(vec == NULL) { //ortho projection onto cardinal plane
|
||||
if((strcmp(plane, "X") == 0) && matSize == 2) {
|
||||
mat[0] = 1.0f;
|
||||
@@ -455,32 +427,42 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
|
||||
PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.OrthoProjection(): unknown plane - expected: X, Y, XY, XZ, YZ");
|
||||
return NULL;
|
||||
}
|
||||
} else { //arbitrary plane
|
||||
}
|
||||
else {
|
||||
//arbitrary plane
|
||||
|
||||
int vec_size= 0;
|
||||
float tvec[4];
|
||||
|
||||
if((vec_size= mathutils_array_parse(tvec, 2, matSize == 2 ? 2 : 3, vec, "Matrix.OrthoProjection(plane, size, axis), invalid 'axis' arg")) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//normalize arbitrary axis
|
||||
for(x = 0; x < vec->size; x++) {
|
||||
norm += vec->vec[x] * vec->vec[x];
|
||||
for(x = 0; x < vec_size; x++) {
|
||||
norm += tvec[x] * tvec[x];
|
||||
}
|
||||
norm = (float) sqrt(norm);
|
||||
for(x = 0; x < vec->size; x++) {
|
||||
vec->vec[x] /= norm;
|
||||
for(x = 0; x < vec_size; x++) {
|
||||
tvec[x] /= norm;
|
||||
}
|
||||
if((strcmp(plane, "R") == 0) && matSize == 2) {
|
||||
mat[0] = 1 - (vec->vec[0] * vec->vec[0]);
|
||||
mat[1] = -(vec->vec[0] * vec->vec[1]);
|
||||
mat[2] = -(vec->vec[0] * vec->vec[1]);
|
||||
mat[3] = 1 - (vec->vec[1] * vec->vec[1]);
|
||||
mat[0] = 1 - (tvec[0] * tvec[0]);
|
||||
mat[1] = -(tvec[0] * tvec[1]);
|
||||
mat[2] = -(tvec[0] * tvec[1]);
|
||||
mat[3] = 1 - (tvec[1] * tvec[1]);
|
||||
} else if((strcmp(plane, "R") == 0) && matSize > 2) {
|
||||
mat[0] = 1 - (vec->vec[0] * vec->vec[0]);
|
||||
mat[1] = -(vec->vec[0] * vec->vec[1]);
|
||||
mat[2] = -(vec->vec[0] * vec->vec[2]);
|
||||
mat[3] = -(vec->vec[0] * vec->vec[1]);
|
||||
mat[4] = 1 - (vec->vec[1] * vec->vec[1]);
|
||||
mat[5] = -(vec->vec[1] * vec->vec[2]);
|
||||
mat[6] = -(vec->vec[0] * vec->vec[2]);
|
||||
mat[7] = -(vec->vec[1] * vec->vec[2]);
|
||||
mat[8] = 1 - (vec->vec[2] * vec->vec[2]);
|
||||
mat[0] = 1 - (tvec[0] * tvec[0]);
|
||||
mat[1] = -(tvec[0] * tvec[1]);
|
||||
mat[2] = -(tvec[0] * tvec[2]);
|
||||
mat[3] = -(tvec[0] * tvec[1]);
|
||||
mat[4] = 1 - (tvec[1] * tvec[1]);
|
||||
mat[5] = -(tvec[1] * tvec[2]);
|
||||
mat[6] = -(tvec[0] * tvec[2]);
|
||||
mat[7] = -(tvec[1] * tvec[2]);
|
||||
mat[8] = 1 - (tvec[2] * tvec[2]);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.OrthoProjection(): unknown plane - expected: 'r' expected for axis designation");
|
||||
PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.OrthoProjection(): unknown plane - expected: 'R' expected for axis designation");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -516,7 +498,7 @@ static char C_Matrix_Shear_doc[] =
|
||||
static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args)
|
||||
{
|
||||
int matSize;
|
||||
char *plane;
|
||||
const char *plane;
|
||||
PyObject *fac;
|
||||
float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
|
||||
@@ -606,7 +588,7 @@ static void matrix_as_3x3(float mat[3][3], MatrixObject *self)
|
||||
}
|
||||
|
||||
/* assumes rowsize == colsize is checked and the read callback has run */
|
||||
static float matrix_determinant(MatrixObject * self)
|
||||
static float matrix_determinant_internal(MatrixObject *self)
|
||||
{
|
||||
if(self->rowSize == 2) {
|
||||
return determinant_m2(self->matrix[0][0], self->matrix[0][1],
|
||||
@@ -624,7 +606,7 @@ static float matrix_determinant(MatrixObject * self)
|
||||
|
||||
|
||||
/*-----------------------------METHODS----------------------------*/
|
||||
static char Matrix_toQuat_doc[] =
|
||||
static char Matrix_to_quaternion_doc[] =
|
||||
".. method:: to_quat()\n"
|
||||
"\n"
|
||||
" Return a quaternion representation of the rotation matrix.\n"
|
||||
@@ -632,29 +614,29 @@ static char Matrix_toQuat_doc[] =
|
||||
" :return: Quaternion representation of the rotation matrix.\n"
|
||||
" :rtype: :class:`Quaternion`\n";
|
||||
|
||||
static PyObject *Matrix_toQuat(MatrixObject * self)
|
||||
static PyObject *Matrix_to_quaternion(MatrixObject *self)
|
||||
{
|
||||
float quat[4];
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
|
||||
/*must be 3-4 cols, 3-4 rows, square matrix*/
|
||||
if((self->colSize < 3) || (self->rowSize < 3) || (self->colSize != self->rowSize)) {
|
||||
PyErr_SetString(PyExc_AttributeError, "Matrix.to_quat(): inappropriate matrix size - expects 3x3 or 4x4 matrix");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if(self->colSize == 3){
|
||||
mat3_to_quat( quat,(float (*)[3])self->contigPtr);
|
||||
}else{
|
||||
mat4_to_quat( quat,(float (*)[4])self->contigPtr);
|
||||
}
|
||||
|
||||
|
||||
return newQuaternionObject(quat, Py_NEW, NULL);
|
||||
}
|
||||
|
||||
/*---------------------------Matrix.toEuler() --------------------*/
|
||||
static char Matrix_toEuler_doc[] =
|
||||
static char Matrix_to_euler_doc[] =
|
||||
".. method:: to_euler(order, euler_compat)\n"
|
||||
"\n"
|
||||
" Return an Euler representation of the rotation matrix (3x3 or 4x4 matrix only).\n"
|
||||
@@ -666,29 +648,29 @@ static char Matrix_toEuler_doc[] =
|
||||
" :return: Euler representation of the matrix.\n"
|
||||
" :rtype: :class:`Euler`\n";
|
||||
|
||||
PyObject *Matrix_toEuler(MatrixObject * self, PyObject *args)
|
||||
PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
|
||||
{
|
||||
char *order_str= NULL;
|
||||
const char *order_str= NULL;
|
||||
short order= EULER_ORDER_XYZ;
|
||||
float eul[3], eul_compatf[3];
|
||||
EulerObject *eul_compat = NULL;
|
||||
|
||||
float tmat[3][3];
|
||||
float (*mat)[3];
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
|
||||
if(!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
|
||||
return NULL;
|
||||
|
||||
|
||||
if(eul_compat) {
|
||||
if(!BaseMath_ReadCallback(eul_compat))
|
||||
return NULL;
|
||||
|
||||
copy_v3_v3(eul_compatf, eul_compat->eul);
|
||||
}
|
||||
|
||||
|
||||
/*must be 3-4 cols, 3-4 rows, square matrix*/
|
||||
if(self->colSize ==3 && self->rowSize ==3) {
|
||||
mat= (float (*)[3])self->contigPtr;
|
||||
@@ -719,7 +701,7 @@ PyObject *Matrix_toEuler(MatrixObject * self, PyObject *args)
|
||||
return newEulerObject(eul, order, Py_NEW, NULL);
|
||||
}
|
||||
/*---------------------------Matrix.resize4x4() ------------------*/
|
||||
static char Matrix_Resize4x4_doc[] =
|
||||
static char Matrix_resize4x4_doc[] =
|
||||
".. method:: resize4x4()\n"
|
||||
"\n"
|
||||
" Resize the matrix to 4x4.\n"
|
||||
@@ -727,7 +709,7 @@ static char Matrix_Resize4x4_doc[] =
|
||||
" :return: an instance of itself.\n"
|
||||
" :rtype: :class:`Matrix`\n";
|
||||
|
||||
PyObject *Matrix_Resize4x4(MatrixObject * self)
|
||||
PyObject *Matrix_resize4x4(MatrixObject *self)
|
||||
{
|
||||
int x, first_row_elem, curr_pos, new_pos, blank_columns, blank_rows, index;
|
||||
|
||||
@@ -739,7 +721,7 @@ PyObject *Matrix_Resize4x4(MatrixObject * self)
|
||||
PyErr_SetString(PyExc_TypeError, "cannot resize owned data - make a copy and resize that");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
self->contigPtr = PyMem_Realloc(self->contigPtr, (sizeof(float) * 16));
|
||||
if(self->contigPtr == NULL) {
|
||||
PyErr_SetString(PyExc_MemoryError, "matrix.resize4x4(): problem allocating pointer space");
|
||||
@@ -774,7 +756,7 @@ PyObject *Matrix_Resize4x4(MatrixObject * self)
|
||||
}
|
||||
self->rowSize = 4;
|
||||
self->colSize = 4;
|
||||
|
||||
|
||||
Py_INCREF(self);
|
||||
return (PyObject *)self;
|
||||
}
|
||||
@@ -786,7 +768,7 @@ static char Matrix_to_4x4_doc[] =
|
||||
"\n"
|
||||
" :return: a new matrix.\n"
|
||||
" :rtype: :class:`Matrix`\n";
|
||||
PyObject *Matrix_to_4x4(MatrixObject * self)
|
||||
PyObject *Matrix_to_4x4(MatrixObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
@@ -812,7 +794,7 @@ static char Matrix_to_3x3_doc[] =
|
||||
"\n"
|
||||
" :return: a new matrix.\n"
|
||||
" :rtype: :class:`Matrix`\n";
|
||||
PyObject *Matrix_to_3x3(MatrixObject * self)
|
||||
PyObject *Matrix_to_3x3(MatrixObject *self)
|
||||
{
|
||||
float mat[3][3];
|
||||
|
||||
@@ -830,7 +812,7 @@ PyObject *Matrix_to_3x3(MatrixObject * self)
|
||||
}
|
||||
|
||||
/*---------------------------Matrix.translationPart() ------------*/
|
||||
static char Matrix_TranslationPart_doc[] =
|
||||
static char Matrix_translation_part_doc[] =
|
||||
".. method:: translation_part()\n"
|
||||
"\n"
|
||||
" Return a the translation part of a 4 row matrix.\n"
|
||||
@@ -838,11 +820,11 @@ static char Matrix_TranslationPart_doc[] =
|
||||
" :return: Return a the translation of a matrix.\n"
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
PyObject *Matrix_TranslationPart(MatrixObject * self)
|
||||
PyObject *Matrix_translation_part(MatrixObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
|
||||
if((self->colSize < 3) || self->rowSize < 4){
|
||||
PyErr_SetString(PyExc_AttributeError, "Matrix.translation_part(): inappropriate matrix size");
|
||||
return NULL;
|
||||
@@ -851,7 +833,7 @@ PyObject *Matrix_TranslationPart(MatrixObject * self)
|
||||
return newVectorObject(self->matrix[3], 3, Py_NEW, NULL);
|
||||
}
|
||||
/*---------------------------Matrix.rotationPart() ---------------*/
|
||||
static char Matrix_RotationPart_doc[] =
|
||||
static char Matrix_rotation_part_doc[] =
|
||||
".. method:: rotation_part()\n"
|
||||
"\n"
|
||||
" Return the 3d submatrix corresponding to the linear term of the embedded affine transformation in 3d. This matrix represents rotation and scale.\n"
|
||||
@@ -861,7 +843,7 @@ static char Matrix_RotationPart_doc[] =
|
||||
"\n"
|
||||
" .. note:: Note that the (4,4) element of a matrix can be used for uniform scaling too.\n";
|
||||
|
||||
PyObject *Matrix_RotationPart(MatrixObject *self)
|
||||
PyObject *Matrix_rotation_part(MatrixObject *self)
|
||||
{
|
||||
float mat[3][3];
|
||||
|
||||
@@ -878,7 +860,7 @@ PyObject *Matrix_RotationPart(MatrixObject *self)
|
||||
return newMatrixObject((float *)mat, 3, 3, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
/*---------------------------Matrix.scalePart() --------------------*/
|
||||
static char Matrix_scalePart_doc[] =
|
||||
static char Matrix_scale_part_doc[] =
|
||||
".. method:: scale_part()\n"
|
||||
"\n"
|
||||
" Return a the scale part of a 3x3 or 4x4 matrix.\n"
|
||||
@@ -888,7 +870,7 @@ static char Matrix_scalePart_doc[] =
|
||||
"\n"
|
||||
" .. note:: This method does not return negative a scale on any axis because it is not possible to obtain this data from the matrix alone.\n";
|
||||
|
||||
PyObject *Matrix_scalePart(MatrixObject * self)
|
||||
PyObject *Matrix_scale_part(MatrixObject *self)
|
||||
{
|
||||
float rot[3][3];
|
||||
float mat[3][3];
|
||||
@@ -912,7 +894,7 @@ PyObject *Matrix_scalePart(MatrixObject * self)
|
||||
}
|
||||
|
||||
/*---------------------------Matrix.invert() ---------------------*/
|
||||
static char Matrix_Invert_doc[] =
|
||||
static char Matrix_invert_doc[] =
|
||||
".. method:: invert()\n"
|
||||
"\n"
|
||||
" Set the matrix to its inverse.\n"
|
||||
@@ -924,9 +906,9 @@ static char Matrix_Invert_doc[] =
|
||||
"\n"
|
||||
" .. seealso:: <http://en.wikipedia.org/wiki/Inverse_matrix>\n";
|
||||
|
||||
PyObject *Matrix_Invert(MatrixObject * self)
|
||||
PyObject *Matrix_invert(MatrixObject *self)
|
||||
{
|
||||
|
||||
|
||||
int x, y, z = 0;
|
||||
float det = 0.0f;
|
||||
float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
@@ -941,7 +923,7 @@ PyObject *Matrix_Invert(MatrixObject * self)
|
||||
}
|
||||
|
||||
/*calculate the determinant*/
|
||||
det = matrix_determinant(self);
|
||||
det = matrix_determinant_internal(self);
|
||||
|
||||
if(det != 0) {
|
||||
/*calculate the classical adjoint*/
|
||||
@@ -967,12 +949,12 @@ PyObject *Matrix_Invert(MatrixObject * self)
|
||||
}
|
||||
}
|
||||
/*transpose
|
||||
Matrix_Transpose(self);*/
|
||||
Matrix_transpose(self);*/
|
||||
} else {
|
||||
PyErr_SetString(PyExc_ValueError, "matrix does not have an inverse");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
Py_INCREF(self);
|
||||
return (PyObject *)self;
|
||||
@@ -986,7 +968,7 @@ static char Matrix_decompose_doc[] =
|
||||
"\n"
|
||||
" :return: loc, rot, scale triple.\n"
|
||||
" :rtype: (:class:`Vector`, :class:`Quaternion`, :class:`Vector`)";
|
||||
static PyObject *Matrix_decompose(MatrixObject * self)
|
||||
static PyObject *Matrix_decompose(MatrixObject *self)
|
||||
{
|
||||
PyObject *ret;
|
||||
float loc[3];
|
||||
@@ -1015,7 +997,7 @@ static PyObject *Matrix_decompose(MatrixObject * self)
|
||||
|
||||
|
||||
|
||||
static char Matrix_Lerp_doc[] =
|
||||
static char Matrix_lerp_doc[] =
|
||||
".. function:: lerp(other, factor)\n"
|
||||
"\n"
|
||||
" Returns the interpolation of two matricies.\n"
|
||||
@@ -1027,7 +1009,7 @@ static char Matrix_Lerp_doc[] =
|
||||
" :return: The interpolated rotation.\n"
|
||||
" :rtype: :class:`Matrix`\n";
|
||||
|
||||
static PyObject *Matrix_Lerp(MatrixObject *self, PyObject *args)
|
||||
static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args)
|
||||
{
|
||||
MatrixObject *mat2 = NULL;
|
||||
float fac, mat[MATRIX_MAX_DIM*MATRIX_MAX_DIM];
|
||||
@@ -1059,7 +1041,7 @@ static PyObject *Matrix_Lerp(MatrixObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
/*---------------------------Matrix.determinant() ----------------*/
|
||||
static char Matrix_Determinant_doc[] =
|
||||
static char Matrix_determinant_doc[] =
|
||||
".. method:: determinant()\n"
|
||||
"\n"
|
||||
" Return the determinant of a matrix.\n"
|
||||
@@ -1069,20 +1051,20 @@ static char Matrix_Determinant_doc[] =
|
||||
"\n"
|
||||
" .. seealso:: <http://en.wikipedia.org/wiki/Determinant>\n";
|
||||
|
||||
PyObject *Matrix_Determinant(MatrixObject * self)
|
||||
PyObject *Matrix_determinant(MatrixObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
|
||||
if(self->rowSize != self->colSize){
|
||||
PyErr_SetString(PyExc_AttributeError, "Matrix.determinant: only square matrices are supported");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble((double)matrix_determinant(self));
|
||||
return PyFloat_FromDouble((double)matrix_determinant_internal(self));
|
||||
}
|
||||
/*---------------------------Matrix.transpose() ------------------*/
|
||||
static char Matrix_Transpose_doc[] =
|
||||
static char Matrix_transpose_doc[] =
|
||||
".. method:: transpose()\n"
|
||||
"\n"
|
||||
" Set the matrix to its transpose.\n"
|
||||
@@ -1092,13 +1074,13 @@ static char Matrix_Transpose_doc[] =
|
||||
"\n"
|
||||
" .. seealso:: <http://en.wikipedia.org/wiki/Transpose>\n";
|
||||
|
||||
PyObject *Matrix_Transpose(MatrixObject * self)
|
||||
PyObject *Matrix_transpose(MatrixObject *self)
|
||||
{
|
||||
float t = 0.0f;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
|
||||
if(self->rowSize != self->colSize){
|
||||
PyErr_SetString(PyExc_AttributeError, "Matrix.transpose(d): only square matrices are supported");
|
||||
return NULL;
|
||||
@@ -1121,7 +1103,7 @@ PyObject *Matrix_Transpose(MatrixObject * self)
|
||||
|
||||
|
||||
/*---------------------------Matrix.zero() -----------------------*/
|
||||
static char Matrix_Zero_doc[] =
|
||||
static char Matrix_zero_doc[] =
|
||||
".. method:: zero()\n"
|
||||
"\n"
|
||||
" Set all the matrix values to zero.\n"
|
||||
@@ -1129,24 +1111,24 @@ static char Matrix_Zero_doc[] =
|
||||
" :return: an instance of itself\n"
|
||||
" :rtype: :class:`Matrix`\n";
|
||||
|
||||
PyObject *Matrix_Zero(MatrixObject * self)
|
||||
PyObject *Matrix_zero(MatrixObject *self)
|
||||
{
|
||||
int row, col;
|
||||
|
||||
|
||||
for(row = 0; row < self->rowSize; row++) {
|
||||
for(col = 0; col < self->colSize; col++) {
|
||||
self->matrix[row][col] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!BaseMath_WriteCallback(self))
|
||||
return NULL;
|
||||
|
||||
|
||||
Py_INCREF(self);
|
||||
return (PyObject *)self;
|
||||
}
|
||||
/*---------------------------Matrix.identity(() ------------------*/
|
||||
static char Matrix_Identity_doc[] =
|
||||
static char Matrix_identity_doc[] =
|
||||
".. method:: identity()\n"
|
||||
"\n"
|
||||
" Set the matrix to the identity matrix.\n"
|
||||
@@ -1158,11 +1140,11 @@ static char Matrix_Identity_doc[] =
|
||||
"\n"
|
||||
" .. seealso:: <http://en.wikipedia.org/wiki/Identity_matrix>\n";
|
||||
|
||||
PyObject *Matrix_Identity(MatrixObject * self)
|
||||
PyObject *Matrix_identity(MatrixObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
|
||||
if(self->rowSize != self->colSize){
|
||||
PyErr_SetString(PyExc_AttributeError, "Matrix.identity: only square matrices are supported");
|
||||
return NULL;
|
||||
@@ -1181,7 +1163,7 @@ PyObject *Matrix_Identity(MatrixObject * self)
|
||||
|
||||
if(!BaseMath_WriteCallback(self))
|
||||
return NULL;
|
||||
|
||||
|
||||
Py_INCREF(self);
|
||||
return (PyObject *)self;
|
||||
}
|
||||
@@ -1199,13 +1181,13 @@ PyObject *Matrix_copy(MatrixObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
|
||||
return (PyObject*)newMatrixObject((float (*))self->contigPtr, self->rowSize, self->colSize, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
|
||||
/*----------------------------print object (internal)-------------*/
|
||||
/*print the object to screen*/
|
||||
static PyObject *Matrix_repr(MatrixObject * self)
|
||||
static PyObject *Matrix_repr(MatrixObject *self)
|
||||
{
|
||||
int x, y;
|
||||
PyObject *rows[MATRIX_MAX_DIM]= {0};
|
||||
@@ -1256,7 +1238,7 @@ static PyObject* Matrix_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
||||
|
||||
if(!BaseMath_ReadCallback(matA) || !BaseMath_ReadCallback(matB))
|
||||
return NULL;
|
||||
|
||||
|
||||
if (matA->colSize != matB->colSize || matA->rowSize != matB->rowSize){
|
||||
if (comparison_type == Py_NE){
|
||||
Py_RETURN_TRUE;
|
||||
@@ -1294,18 +1276,18 @@ static PyObject* Matrix_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
||||
/*---------------------SEQUENCE PROTOCOLS------------------------
|
||||
----------------------------len(object)------------------------
|
||||
sequence length*/
|
||||
static int Matrix_len(MatrixObject * self)
|
||||
static int Matrix_len(MatrixObject *self)
|
||||
{
|
||||
return (self->rowSize);
|
||||
}
|
||||
/*----------------------------object[]---------------------------
|
||||
sequence accessor (get)
|
||||
the wrapped vector gives direct access to the matrix data*/
|
||||
static PyObject *Matrix_item(MatrixObject * self, int i)
|
||||
static PyObject *Matrix_item(MatrixObject *self, int i)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
|
||||
if(i < 0 || i >= self->rowSize) {
|
||||
PyErr_SetString(PyExc_IndexError, "matrix[attribute]: array index out of range");
|
||||
return NULL;
|
||||
@@ -1330,7 +1312,7 @@ static int Matrix_ass_item(MatrixObject *self, int i, PyObject *value)
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(self->matrix[i], vec, self->colSize * sizeof(float));
|
||||
memcpy(self->matrix[i], vec, self->colSize *sizeof(float));
|
||||
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
return 0;
|
||||
@@ -1338,12 +1320,12 @@ static int Matrix_ass_item(MatrixObject *self, int i, PyObject *value)
|
||||
|
||||
/*----------------------------object[z:y]------------------------
|
||||
sequence slice (get)*/
|
||||
static PyObject *Matrix_slice(MatrixObject * self, int begin, int end)
|
||||
static PyObject *Matrix_slice(MatrixObject *self, int begin, int end)
|
||||
{
|
||||
|
||||
PyObject *tuple;
|
||||
int count;
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
@@ -1362,13 +1344,13 @@ static PyObject *Matrix_slice(MatrixObject * self, int begin, int end)
|
||||
}
|
||||
/*----------------------------object[z:y]------------------------
|
||||
sequence slice (set)*/
|
||||
static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject *value)
|
||||
static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *value)
|
||||
{
|
||||
PyObject *value_fast= NULL;
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return -1;
|
||||
|
||||
|
||||
CLAMP(begin, 0, self->rowSize);
|
||||
CLAMP(end, 0, self->rowSize);
|
||||
begin = MIN2(begin,end);
|
||||
@@ -1410,7 +1392,7 @@ static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject *v
|
||||
}
|
||||
/*------------------------NUMERIC PROTOCOLS----------------------
|
||||
------------------------obj + obj------------------------------*/
|
||||
static PyObject *Matrix_add(PyObject * m1, PyObject * m2)
|
||||
static PyObject *Matrix_add(PyObject *m1, PyObject *m2)
|
||||
{
|
||||
float mat[16];
|
||||
MatrixObject *mat1 = NULL, *mat2 = NULL;
|
||||
@@ -1422,10 +1404,10 @@ static PyObject *Matrix_add(PyObject * m1, PyObject * m2)
|
||||
PyErr_SetString(PyExc_AttributeError, "Matrix addition: arguments not valid for this operation");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(mat1) || !BaseMath_ReadCallback(mat2))
|
||||
return NULL;
|
||||
|
||||
|
||||
if(mat1->rowSize != mat2->rowSize || mat1->colSize != mat2->colSize){
|
||||
PyErr_SetString(PyExc_AttributeError, "Matrix addition: matrices must have the same dimensions for this operation");
|
||||
return NULL;
|
||||
@@ -1437,7 +1419,7 @@ static PyObject *Matrix_add(PyObject * m1, PyObject * m2)
|
||||
}
|
||||
/*------------------------obj - obj------------------------------
|
||||
subtraction*/
|
||||
static PyObject *Matrix_sub(PyObject * m1, PyObject * m2)
|
||||
static PyObject *Matrix_sub(PyObject *m1, PyObject *m2)
|
||||
{
|
||||
float mat[16];
|
||||
MatrixObject *mat1 = NULL, *mat2 = NULL;
|
||||
@@ -1449,10 +1431,10 @@ static PyObject *Matrix_sub(PyObject * m1, PyObject * m2)
|
||||
PyErr_SetString(PyExc_AttributeError, "Matrix addition: arguments not valid for this operation");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(mat1) || !BaseMath_ReadCallback(mat2))
|
||||
return NULL;
|
||||
|
||||
|
||||
if(mat1->rowSize != mat2->rowSize || mat1->colSize != mat2->colSize){
|
||||
PyErr_SetString(PyExc_AttributeError, "Matrix addition: matrices must have the same dimensions for this operation");
|
||||
return NULL;
|
||||
@@ -1535,8 +1517,8 @@ static PyObject* Matrix_inv(MatrixObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
return Matrix_Invert(self);
|
||||
|
||||
return Matrix_invert(self);
|
||||
}
|
||||
|
||||
/*-----------------PROTOCOL DECLARATIONS--------------------------*/
|
||||
@@ -1720,24 +1702,24 @@ static PyGetSetDef Matrix_getseters[] = {
|
||||
|
||||
/*-----------------------METHOD DEFINITIONS ----------------------*/
|
||||
static struct PyMethodDef Matrix_methods[] = {
|
||||
{"zero", (PyCFunction) Matrix_Zero, METH_NOARGS, Matrix_Zero_doc},
|
||||
{"identity", (PyCFunction) Matrix_Identity, METH_NOARGS, Matrix_Identity_doc},
|
||||
{"transpose", (PyCFunction) Matrix_Transpose, METH_NOARGS, Matrix_Transpose_doc},
|
||||
{"lerp", (PyCFunction) Matrix_Lerp, METH_VARARGS, Matrix_Lerp_doc},
|
||||
{"determinant", (PyCFunction) Matrix_Determinant, METH_NOARGS, Matrix_Determinant_doc},
|
||||
{"invert", (PyCFunction) Matrix_Invert, METH_NOARGS, Matrix_Invert_doc},
|
||||
{"translation_part", (PyCFunction) Matrix_TranslationPart, METH_NOARGS, Matrix_TranslationPart_doc},
|
||||
{"rotation_part", (PyCFunction) Matrix_RotationPart, METH_NOARGS, Matrix_RotationPart_doc},
|
||||
{"scale_part", (PyCFunction) Matrix_scalePart, METH_NOARGS, Matrix_scalePart_doc},
|
||||
{"zero", (PyCFunction) Matrix_zero, METH_NOARGS, Matrix_zero_doc},
|
||||
{"identity", (PyCFunction) Matrix_identity, METH_NOARGS, Matrix_identity_doc},
|
||||
{"transpose", (PyCFunction) Matrix_transpose, METH_NOARGS, Matrix_transpose_doc},
|
||||
{"lerp", (PyCFunction) Matrix_lerp, METH_VARARGS, Matrix_lerp_doc},
|
||||
{"determinant", (PyCFunction) Matrix_determinant, METH_NOARGS, Matrix_determinant_doc},
|
||||
{"invert", (PyCFunction) Matrix_invert, METH_NOARGS, Matrix_invert_doc},
|
||||
{"translation_part", (PyCFunction) Matrix_translation_part, METH_NOARGS, Matrix_translation_part_doc},
|
||||
{"rotation_part", (PyCFunction) Matrix_rotation_part, METH_NOARGS, Matrix_rotation_part_doc},
|
||||
{"scale_part", (PyCFunction) Matrix_scale_part, METH_NOARGS, Matrix_scale_part_doc},
|
||||
{"decompose", (PyCFunction) Matrix_decompose, METH_NOARGS, Matrix_decompose_doc},
|
||||
{"resize4x4", (PyCFunction) Matrix_Resize4x4, METH_NOARGS, Matrix_Resize4x4_doc},
|
||||
{"resize4x4", (PyCFunction) Matrix_resize4x4, METH_NOARGS, Matrix_resize4x4_doc},
|
||||
{"to_4x4", (PyCFunction) Matrix_to_4x4, METH_NOARGS, Matrix_to_4x4_doc},
|
||||
{"to_3x3", (PyCFunction) Matrix_to_3x3, METH_NOARGS, Matrix_to_3x3_doc},
|
||||
{"to_euler", (PyCFunction) Matrix_toEuler, METH_VARARGS, Matrix_toEuler_doc},
|
||||
{"to_quat", (PyCFunction) Matrix_toQuat, METH_NOARGS, Matrix_toQuat_doc},
|
||||
{"to_euler", (PyCFunction) Matrix_to_euler, METH_VARARGS, Matrix_to_euler_doc},
|
||||
{"to_quat", (PyCFunction) Matrix_to_quaternion, METH_NOARGS, Matrix_to_quaternion_doc},
|
||||
{"copy", (PyCFunction) Matrix_copy, METH_NOARGS, Matrix_copy_doc},
|
||||
{"__copy__", (PyCFunction) Matrix_copy, METH_NOARGS, Matrix_copy_doc},
|
||||
|
||||
|
||||
/* class methods */
|
||||
{"Rotation", (PyCFunction) C_Matrix_Rotation, METH_VARARGS | METH_CLASS, C_Matrix_Rotation_doc},
|
||||
{"Scale", (PyCFunction) C_Matrix_Scale, METH_VARARGS | METH_CLASS, C_Matrix_Scale_doc},
|
||||
@@ -1832,7 +1814,7 @@ PyObject *newMatrixObject(float *mat, const unsigned short rowSize, const unsign
|
||||
|
||||
self->rowSize = rowSize;
|
||||
self->colSize = colSize;
|
||||
|
||||
|
||||
/* init callbacks as NULL */
|
||||
self->cb_user= NULL;
|
||||
self->cb_type= self->cb_subtype= 0;
|
||||
@@ -1862,7 +1844,7 @@ PyObject *newMatrixObject(float *mat, const unsigned short rowSize, const unsign
|
||||
}
|
||||
}
|
||||
} else if (rowSize == colSize ) { /*or if no arguments are passed return identity matrix for square matrices */
|
||||
Matrix_Identity(self);
|
||||
Matrix_identity(self);
|
||||
Py_DECREF(self);
|
||||
}
|
||||
self->wrapped = Py_NEW;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Contributor(s): Joseph Gilbert
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
@@ -38,7 +38,7 @@
|
||||
//-----------------------------METHODS------------------------------
|
||||
|
||||
/* note: BaseMath_ReadCallback must be called beforehand */
|
||||
static PyObject *Quaternion_ToTupleExt(QuaternionObject *self, int ndigits)
|
||||
static PyObject *Quaternion_to_tuple_ext(QuaternionObject *self, int ndigits)
|
||||
{
|
||||
PyObject *ret;
|
||||
int i;
|
||||
@@ -59,7 +59,7 @@ static PyObject *Quaternion_ToTupleExt(QuaternionObject *self, int ndigits)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char Quaternion_ToEuler_doc[] =
|
||||
static char Quaternion_to_euler_doc[] =
|
||||
".. method:: to_euler(order, euler_compat)\n"
|
||||
"\n"
|
||||
" Return Euler representation of the quaternion.\n"
|
||||
@@ -69,19 +69,19 @@ static char Quaternion_ToEuler_doc[] =
|
||||
" :arg euler_compat: Optional euler argument the new euler will be made compatible with (no axis flipping between them). Useful for converting a series of matrices to animation curves.\n"
|
||||
" :type euler_compat: :class:`Euler`\n"
|
||||
" :return: Euler representation of the quaternion.\n"
|
||||
" :rtype: :class:`Euler`\n";
|
||||
|
||||
static PyObject *Quaternion_ToEuler(QuaternionObject * self, PyObject *args)
|
||||
" :rtype: :class:`Euler`\n"
|
||||
;
|
||||
static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
|
||||
{
|
||||
float tquat[4];
|
||||
float eul[3];
|
||||
char *order_str= NULL;
|
||||
const char *order_str= NULL;
|
||||
short order= EULER_ORDER_XYZ;
|
||||
EulerObject *eul_compat = NULL;
|
||||
|
||||
|
||||
if(!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
|
||||
return NULL;
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
@@ -91,15 +91,15 @@ static PyObject *Quaternion_ToEuler(QuaternionObject * self, PyObject *args)
|
||||
if(order == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
normalize_qt_qt(tquat, self->quat);
|
||||
|
||||
if(eul_compat) {
|
||||
float mat[3][3];
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(eul_compat))
|
||||
return NULL;
|
||||
|
||||
|
||||
quat_to_mat3(mat, tquat);
|
||||
|
||||
if(order == EULER_ORDER_XYZ) mat3_to_compatible_eul(eul, eul_compat->eul, mat);
|
||||
@@ -109,19 +109,19 @@ static PyObject *Quaternion_ToEuler(QuaternionObject * self, PyObject *args)
|
||||
if(order == EULER_ORDER_XYZ) quat_to_eul(eul, tquat);
|
||||
else quat_to_eulO(eul, order, tquat);
|
||||
}
|
||||
|
||||
|
||||
return newEulerObject(eul, order, Py_NEW, NULL);
|
||||
}
|
||||
//----------------------------Quaternion.toMatrix()------------------
|
||||
static char Quaternion_ToMatrix_doc[] =
|
||||
static char 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 *Quaternion_ToMatrix(QuaternionObject * self)
|
||||
" :rtype: :class:`Matrix`\n"
|
||||
;
|
||||
static PyObject *Quaternion_to_matrix(QuaternionObject *self)
|
||||
{
|
||||
float mat[9]; /* all values are set */
|
||||
|
||||
@@ -133,7 +133,7 @@ static PyObject *Quaternion_ToMatrix(QuaternionObject * self)
|
||||
}
|
||||
|
||||
//----------------------------Quaternion.cross(other)------------------
|
||||
static char Quaternion_Cross_doc[] =
|
||||
static char Quaternion_cross_doc[] =
|
||||
".. method:: cross(other)\n"
|
||||
"\n"
|
||||
" Return the cross product of this quaternion and another.\n"
|
||||
@@ -141,26 +141,24 @@ static char Quaternion_Cross_doc[] =
|
||||
" :arg 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 *Quaternion_Cross(QuaternionObject *self, QuaternionObject *value)
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value)
|
||||
{
|
||||
float quat[QUAT_SIZE];
|
||||
|
||||
if (!QuaternionObject_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError, "quat.cross(value): expected a quaternion argument, not %.200s", Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
float quat[QUAT_SIZE], tquat[QUAT_SIZE];
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
mul_qt_qtqt(quat, self->quat, value->quat);
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.cross(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
mul_qt_qtqt(quat, self->quat, tquat);
|
||||
return newQuaternionObject(quat, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
|
||||
//----------------------------Quaternion.dot(other)------------------
|
||||
static char Quaternion_Dot_doc[] =
|
||||
static char Quaternion_dot_doc[] =
|
||||
".. method:: dot(other)\n"
|
||||
"\n"
|
||||
" Return the dot product of this quaternion and another.\n"
|
||||
@@ -168,22 +166,22 @@ static char Quaternion_Dot_doc[] =
|
||||
" :arg other: The other quaternion to perform the dot product with.\n"
|
||||
" :type other: :class:`Quaternion`\n"
|
||||
" :return: The dot product.\n"
|
||||
" :rtype: :class:`Quaternion`\n";
|
||||
|
||||
static PyObject *Quaternion_Dot(QuaternionObject * self, QuaternionObject * value)
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value)
|
||||
{
|
||||
if (!QuaternionObject_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError, "quat.dot(value): expected a quaternion argument, not %.200s", Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
float tquat[QUAT_SIZE];
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(dot_qtqt(self->quat, value->quat));
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.dot(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
return PyFloat_FromDouble(dot_qtqt(self->quat, tquat));
|
||||
}
|
||||
|
||||
static char Quaternion_Difference_doc[] =
|
||||
static char Quaternion_difference_doc[] =
|
||||
".. function:: difference(other)\n"
|
||||
"\n"
|
||||
" Returns a quaternion representing the rotational difference.\n"
|
||||
@@ -191,26 +189,24 @@ static char Quaternion_Difference_doc[] =
|
||||
" :arg 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 *Quaternion_Difference(QuaternionObject * self, QuaternionObject * value)
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Quaternion_difference(QuaternionObject *self, PyObject *value)
|
||||
{
|
||||
float quat[QUAT_SIZE];
|
||||
float tquat[QUAT_SIZE], quat[QUAT_SIZE];
|
||||
|
||||
if (!QuaternionObject_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError, "quat.difference(value): expected a quaternion argument, not %.200s", Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
rotation_between_quats_to_quat(quat, self->quat, value->quat);
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.difference(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
rotation_between_quats_to_quat(quat, self->quat, tquat);
|
||||
|
||||
return newQuaternionObject(quat, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
|
||||
static char Quaternion_Slerp_doc[] =
|
||||
static char Quaternion_slerp_doc[] =
|
||||
".. function:: slerp(other, factor)\n"
|
||||
"\n"
|
||||
" Returns the interpolation of two quaternions.\n"
|
||||
@@ -220,19 +216,22 @@ static char Quaternion_Slerp_doc[] =
|
||||
" :arg 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 *Quaternion_Slerp(QuaternionObject *self, PyObject *args)
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args)
|
||||
{
|
||||
QuaternionObject *value;
|
||||
float quat[QUAT_SIZE], fac;
|
||||
PyObject *value;
|
||||
float tquat[QUAT_SIZE], quat[QUAT_SIZE], fac;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!f:slerp", &quaternion_Type, &value, &fac)) {
|
||||
if(!PyArg_ParseTuple(args, "Of:slerp", &value, &fac)) {
|
||||
PyErr_SetString(PyExc_TypeError, "quat.slerp(): expected Quaternion types and float");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.slerp(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
if(fac > 1.0f || fac < 0.0f) {
|
||||
@@ -240,22 +239,22 @@ static PyObject *Quaternion_Slerp(QuaternionObject *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
interp_qt_qtqt(quat, self->quat, value->quat, fac);
|
||||
interp_qt_qtqt(quat, self->quat, tquat, fac);
|
||||
|
||||
return newQuaternionObject(quat, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
|
||||
//----------------------------Quaternion.normalize()----------------
|
||||
//normalize the axis of rotation of [theta,vector]
|
||||
static char Quaternion_Normalize_doc[] =
|
||||
static char Quaternion_normalize_doc[] =
|
||||
".. function:: normalize()\n"
|
||||
"\n"
|
||||
" Normalize the quaternion.\n"
|
||||
"\n"
|
||||
" :return: an instance of itself.\n"
|
||||
" :rtype: :class:`Quaternion`\n";
|
||||
|
||||
static PyObject *Quaternion_Normalize(QuaternionObject * self)
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Quaternion_normalize(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
@@ -267,15 +266,15 @@ static PyObject *Quaternion_Normalize(QuaternionObject * self)
|
||||
return (PyObject*)self;
|
||||
}
|
||||
//----------------------------Quaternion.inverse()------------------
|
||||
static char Quaternion_Inverse_doc[] =
|
||||
static char Quaternion_inverse_doc[] =
|
||||
".. function:: inverse()\n"
|
||||
"\n"
|
||||
" Set the quaternion to its inverse.\n"
|
||||
"\n"
|
||||
" :return: an instance of itself.\n"
|
||||
" :rtype: :class:`Quaternion`\n";
|
||||
|
||||
static PyObject *Quaternion_Inverse(QuaternionObject * self)
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Quaternion_inverse(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
@@ -287,15 +286,15 @@ static PyObject *Quaternion_Inverse(QuaternionObject * self)
|
||||
return (PyObject*)self;
|
||||
}
|
||||
//----------------------------Quaternion.identity()-----------------
|
||||
static char Quaternion_Identity_doc[] =
|
||||
static char Quaternion_identity_doc[] =
|
||||
".. function:: identity()\n"
|
||||
"\n"
|
||||
" Set the quaternion to an identity quaternion.\n"
|
||||
"\n"
|
||||
" :return: an instance of itself.\n"
|
||||
" :rtype: :class:`Quaternion`\n";
|
||||
|
||||
static PyObject *Quaternion_Identity(QuaternionObject * self)
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Quaternion_identity(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
@@ -307,15 +306,15 @@ static PyObject *Quaternion_Identity(QuaternionObject * self)
|
||||
return (PyObject*)self;
|
||||
}
|
||||
//----------------------------Quaternion.negate()-------------------
|
||||
static char Quaternion_Negate_doc[] =
|
||||
static char Quaternion_negate_doc[] =
|
||||
".. function:: negate()\n"
|
||||
"\n"
|
||||
" Set the quaternion to its negative.\n"
|
||||
"\n"
|
||||
" :return: an instance of itself.\n"
|
||||
" :rtype: :class:`Quaternion`\n";
|
||||
|
||||
static PyObject *Quaternion_Negate(QuaternionObject * self)
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Quaternion_negate(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
@@ -327,15 +326,15 @@ static PyObject *Quaternion_Negate(QuaternionObject * self)
|
||||
return (PyObject*)self;
|
||||
}
|
||||
//----------------------------Quaternion.conjugate()----------------
|
||||
static char Quaternion_Conjugate_doc[] =
|
||||
static char Quaternion_conjugate_doc[] =
|
||||
".. function:: conjugate()\n"
|
||||
"\n"
|
||||
" Set the quaternion to its conjugate (negate x, y, z).\n"
|
||||
"\n"
|
||||
" :return: an instance of itself.\n"
|
||||
" :rtype: :class:`Quaternion`\n";
|
||||
|
||||
static PyObject *Quaternion_Conjugate(QuaternionObject * self)
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Quaternion_conjugate(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
@@ -355,8 +354,8 @@ static char Quaternion_copy_doc[] =
|
||||
" :return: A copy of the quaternion.\n"
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
"\n"
|
||||
" .. note:: use this to get a copy of a wrapped quaternion with no reference to the original data.\n";
|
||||
|
||||
" .. note:: use this to get a copy of a wrapped quaternion with no reference to the original data.\n"
|
||||
;
|
||||
static PyObject *Quaternion_copy(QuaternionObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
@@ -367,14 +366,14 @@ static PyObject *Quaternion_copy(QuaternionObject *self)
|
||||
|
||||
//----------------------------print object (internal)--------------
|
||||
//print the object to screen
|
||||
static PyObject *Quaternion_repr(QuaternionObject * self)
|
||||
static PyObject *Quaternion_repr(QuaternionObject *self)
|
||||
{
|
||||
PyObject *ret, *tuple;
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
tuple= Quaternion_ToTupleExt(self, -1);
|
||||
tuple= Quaternion_to_tuple_ext(self, -1);
|
||||
|
||||
ret= PyUnicode_FromFormat("Quaternion(%R)", tuple);
|
||||
|
||||
@@ -440,7 +439,7 @@ static int Quaternion_len(QuaternionObject *UNUSED(self))
|
||||
}
|
||||
//----------------------------object[]---------------------------
|
||||
//sequence accessor (get)
|
||||
static PyObject *Quaternion_item(QuaternionObject * self, int i)
|
||||
static PyObject *Quaternion_item(QuaternionObject *self, int i)
|
||||
{
|
||||
if(i<0) i= QUAT_SIZE-i;
|
||||
|
||||
@@ -457,7 +456,7 @@ static PyObject *Quaternion_item(QuaternionObject * self, int i)
|
||||
}
|
||||
//----------------------------object[]-------------------------
|
||||
//sequence accessor (set)
|
||||
static int Quaternion_ass_item(QuaternionObject * self, int i, PyObject * ob)
|
||||
static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
|
||||
{
|
||||
float scalar= (float)PyFloat_AsDouble(ob);
|
||||
if(scalar==-1.0f && PyErr_Occurred()) { /* parsed item not a number */
|
||||
@@ -480,7 +479,7 @@ static int Quaternion_ass_item(QuaternionObject * self, int i, PyObject * ob)
|
||||
}
|
||||
//----------------------------object[z:y]------------------------
|
||||
//sequence slice (get)
|
||||
static PyObject *Quaternion_slice(QuaternionObject * self, int begin, int end)
|
||||
static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
|
||||
{
|
||||
PyObject *tuple;
|
||||
int count;
|
||||
@@ -502,7 +501,7 @@ static PyObject *Quaternion_slice(QuaternionObject * self, int begin, int end)
|
||||
}
|
||||
//----------------------------object[z:y]------------------------
|
||||
//sequence slice (set)
|
||||
static int Quaternion_ass_slice(QuaternionObject * self, int begin, int end, PyObject * seq)
|
||||
static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyObject *seq)
|
||||
{
|
||||
int i, size;
|
||||
float quat[QUAT_SIZE];
|
||||
@@ -517,7 +516,7 @@ static int Quaternion_ass_slice(QuaternionObject * self, int begin, int end, PyO
|
||||
|
||||
if((size=mathutils_array_parse(quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1)
|
||||
return -1;
|
||||
|
||||
|
||||
if(size != (end - begin)){
|
||||
PyErr_SetString(PyExc_TypeError, "quaternion[begin:end] = []: size mismatch in slice assignment");
|
||||
return -1;
|
||||
@@ -598,7 +597,7 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
|
||||
//------------------------NUMERIC PROTOCOLS----------------------
|
||||
//------------------------obj + obj------------------------------
|
||||
//addition
|
||||
static PyObject *Quaternion_add(PyObject * q1, PyObject * q2)
|
||||
static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
|
||||
{
|
||||
float quat[QUAT_SIZE];
|
||||
QuaternionObject *quat1 = NULL, *quat2 = NULL;
|
||||
@@ -609,7 +608,7 @@ static PyObject *Quaternion_add(PyObject * q1, PyObject * q2)
|
||||
}
|
||||
quat1 = (QuaternionObject*)q1;
|
||||
quat2 = (QuaternionObject*)q2;
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(quat1) || !BaseMath_ReadCallback(quat2))
|
||||
return NULL;
|
||||
|
||||
@@ -618,7 +617,7 @@ static PyObject *Quaternion_add(PyObject * q1, PyObject * q2)
|
||||
}
|
||||
//------------------------obj - obj------------------------------
|
||||
//subtraction
|
||||
static PyObject *Quaternion_sub(PyObject * q1, PyObject * q2)
|
||||
static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
|
||||
{
|
||||
int x;
|
||||
float quat[QUAT_SIZE];
|
||||
@@ -628,10 +627,10 @@ static PyObject *Quaternion_sub(PyObject * q1, PyObject * q2)
|
||||
PyErr_SetString(PyExc_AttributeError, "Quaternion addition: arguments not valid for this operation");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
quat1 = (QuaternionObject*)q1;
|
||||
quat2 = (QuaternionObject*)q2;
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(quat1) || !BaseMath_ReadCallback(quat2))
|
||||
return NULL;
|
||||
|
||||
@@ -652,7 +651,7 @@ static PyObject *quat_mul_float(QuaternionObject *quat, const float scalar)
|
||||
|
||||
//------------------------obj * obj------------------------------
|
||||
//mulplication
|
||||
static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2)
|
||||
static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
|
||||
{
|
||||
float quat[QUAT_SIZE], scalar;
|
||||
QuaternionObject *quat1 = NULL, *quat2 = NULL;
|
||||
@@ -748,17 +747,17 @@ static PyNumberMethods Quaternion_NumMethods = {
|
||||
0, /* nb_index */
|
||||
};
|
||||
|
||||
static PyObject *Quaternion_getAxis( QuaternionObject * self, void *type )
|
||||
static PyObject *Quaternion_getAxis( QuaternionObject *self, void *type )
|
||||
{
|
||||
return Quaternion_item(self, GET_INT_FROM_POINTER(type));
|
||||
}
|
||||
|
||||
static int Quaternion_setAxis( QuaternionObject * self, PyObject * value, void * type )
|
||||
static int Quaternion_setAxis( QuaternionObject *self, PyObject *value, void *type )
|
||||
{
|
||||
return Quaternion_ass_item(self, GET_INT_FROM_POINTER(type), value);
|
||||
}
|
||||
|
||||
static PyObject *Quaternion_getMagnitude(QuaternionObject * self, void *UNUSED(closure))
|
||||
static PyObject *Quaternion_getMagnitude(QuaternionObject *self, void *UNUSED(closure))
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
@@ -766,7 +765,7 @@ static PyObject *Quaternion_getMagnitude(QuaternionObject * self, void *UNUSED(c
|
||||
return PyFloat_FromDouble(sqrt(dot_qtqt(self->quat, self->quat)));
|
||||
}
|
||||
|
||||
static PyObject *Quaternion_getAngle(QuaternionObject * self, void *UNUSED(closure))
|
||||
static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closure))
|
||||
{
|
||||
float tquat[4];
|
||||
|
||||
@@ -777,11 +776,11 @@ static PyObject *Quaternion_getAngle(QuaternionObject * self, void *UNUSED(closu
|
||||
return PyFloat_FromDouble(2.0 * (saacos(tquat[0])));
|
||||
}
|
||||
|
||||
static int Quaternion_setAngle(QuaternionObject * self, PyObject * value, void *UNUSED(closure))
|
||||
static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UNUSED(closure))
|
||||
{
|
||||
float tquat[4];
|
||||
float len;
|
||||
|
||||
|
||||
float axis[3], angle_dummy;
|
||||
double angle;
|
||||
|
||||
@@ -807,7 +806,7 @@ static int Quaternion_setAngle(QuaternionObject * self, PyObject * value, void *
|
||||
) {
|
||||
axis[0] = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
axis_angle_to_quat(self->quat, axis, angle);
|
||||
mul_qt_fl(self->quat, len);
|
||||
|
||||
@@ -820,7 +819,7 @@ static int Quaternion_setAngle(QuaternionObject * self, PyObject * value, void *
|
||||
static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(closure))
|
||||
{
|
||||
float tquat[4];
|
||||
|
||||
|
||||
float axis[3];
|
||||
float angle;
|
||||
|
||||
@@ -848,26 +847,17 @@ static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *
|
||||
|
||||
float axis[3];
|
||||
float angle;
|
||||
|
||||
VectorObject *vec;
|
||||
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return -1;
|
||||
|
||||
len= normalize_qt_qt(tquat, self->quat);
|
||||
quat_to_axis_angle(axis, &angle, tquat);
|
||||
quat_to_axis_angle(axis, &angle, tquat); /* axis value is unused */
|
||||
|
||||
if(!VectorObject_Check(value)) {
|
||||
PyErr_SetString(PyExc_TypeError, "quaternion.axis = value: expected a 3D Vector");
|
||||
return -1;
|
||||
}
|
||||
|
||||
vec= (VectorObject *)value;
|
||||
if(!BaseMath_ReadCallback(vec))
|
||||
if (mathutils_array_parse(axis, 3, 3, value, "quat.axis = other") == -1)
|
||||
return -1;
|
||||
|
||||
axis_angle_to_quat(self->quat, vec->vec, angle);
|
||||
axis_angle_to_quat(self->quat, axis, angle);
|
||||
mul_qt_fl(self->quat, len);
|
||||
|
||||
if(!BaseMath_WriteCallback(self))
|
||||
@@ -887,7 +877,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
|
||||
PyErr_SetString(PyExc_TypeError, "mathutils.Quaternion(): takes no keyword args");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if(!PyArg_ParseTuple(args, "|Od:mathutils.Quaternion", &seq, &angle))
|
||||
return NULL;
|
||||
|
||||
@@ -912,17 +902,17 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
|
||||
|
||||
//-----------------------METHOD DEFINITIONS ----------------------
|
||||
static struct PyMethodDef Quaternion_methods[] = {
|
||||
{"identity", (PyCFunction) Quaternion_Identity, METH_NOARGS, Quaternion_Identity_doc},
|
||||
{"negate", (PyCFunction) Quaternion_Negate, METH_NOARGS, Quaternion_Negate_doc},
|
||||
{"conjugate", (PyCFunction) Quaternion_Conjugate, METH_NOARGS, Quaternion_Conjugate_doc},
|
||||
{"inverse", (PyCFunction) Quaternion_Inverse, METH_NOARGS, Quaternion_Inverse_doc},
|
||||
{"normalize", (PyCFunction) Quaternion_Normalize, METH_NOARGS, Quaternion_Normalize_doc},
|
||||
{"to_euler", (PyCFunction) Quaternion_ToEuler, METH_VARARGS, Quaternion_ToEuler_doc},
|
||||
{"to_matrix", (PyCFunction) Quaternion_ToMatrix, METH_NOARGS, Quaternion_ToMatrix_doc},
|
||||
{"cross", (PyCFunction) Quaternion_Cross, METH_O, Quaternion_Cross_doc},
|
||||
{"dot", (PyCFunction) Quaternion_Dot, METH_O, Quaternion_Dot_doc},
|
||||
{"difference", (PyCFunction) Quaternion_Difference, METH_O, Quaternion_Difference_doc},
|
||||
{"slerp", (PyCFunction) Quaternion_Slerp, METH_VARARGS, Quaternion_Slerp_doc},
|
||||
{"identity", (PyCFunction) Quaternion_identity, METH_NOARGS, Quaternion_identity_doc},
|
||||
{"negate", (PyCFunction) Quaternion_negate, METH_NOARGS, Quaternion_negate_doc},
|
||||
{"conjugate", (PyCFunction) Quaternion_conjugate, METH_NOARGS, Quaternion_conjugate_doc},
|
||||
{"inverse", (PyCFunction) Quaternion_inverse, METH_NOARGS, Quaternion_inverse_doc},
|
||||
{"normalize", (PyCFunction) Quaternion_normalize, METH_NOARGS, Quaternion_normalize_doc},
|
||||
{"to_euler", (PyCFunction) Quaternion_to_euler, METH_VARARGS, Quaternion_to_euler_doc},
|
||||
{"to_matrix", (PyCFunction) Quaternion_to_matrix, METH_NOARGS, Quaternion_to_matrix_doc},
|
||||
{"cross", (PyCFunction) Quaternion_cross, METH_O, Quaternion_cross_doc},
|
||||
{"dot", (PyCFunction) Quaternion_dot, METH_O, Quaternion_dot_doc},
|
||||
{"difference", (PyCFunction) Quaternion_difference, METH_O, Quaternion_difference_doc},
|
||||
{"slerp", (PyCFunction) Quaternion_slerp, METH_VARARGS, Quaternion_slerp_doc},
|
||||
{"__copy__", (PyCFunction) Quaternion_copy, METH_NOARGS, Quaternion_copy_doc},
|
||||
{"copy", (PyCFunction) Quaternion_copy, METH_NOARGS, Quaternion_copy_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
@@ -946,8 +936,8 @@ static PyGetSetDef Quaternion_getseters[] = {
|
||||
|
||||
//------------------PY_OBECT DEFINITION--------------------------
|
||||
static char quaternion_doc[] =
|
||||
"This object gives access to Quaternions in Blender.";
|
||||
|
||||
"This object gives access to Quaternions in Blender."
|
||||
;
|
||||
PyTypeObject quaternion_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"mathutils.Quaternion", //tp_name
|
||||
@@ -1005,7 +995,7 @@ PyTypeObject quaternion_Type = {
|
||||
PyObject *newQuaternionObject(float *quat, int type, PyTypeObject *base_type)
|
||||
{
|
||||
QuaternionObject *self;
|
||||
|
||||
|
||||
if(base_type) self = (QuaternionObject *)base_type->tp_alloc(base_type, 0);
|
||||
else self = PyObject_NEW(QuaternionObject, &quaternion_Type);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#define SWIZZLE_VALID_AXIS 0x4
|
||||
#define SWIZZLE_AXIS 0x3
|
||||
|
||||
static PyObject *Vector_ToTupleExt(VectorObject *self, int ndigits);
|
||||
static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits);
|
||||
|
||||
//----------------------------------mathutils.Vector() ------------------
|
||||
// Supports 2D, 3D, and 4D vector objects both int and float values
|
||||
@@ -66,15 +66,15 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED
|
||||
}
|
||||
|
||||
/*-----------------------------METHODS---------------------------- */
|
||||
static char Vector_Zero_doc[] =
|
||||
static char Vector_zero_doc[] =
|
||||
".. method:: zero()\n"
|
||||
"\n"
|
||||
" Set all values to zero.\n"
|
||||
"\n"
|
||||
" :return: an instance of itself\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Zero(VectorObject *self)
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
static PyObject *Vector_zero(VectorObject *self)
|
||||
{
|
||||
fill_vn(self->vec, self->size, 0.0f);
|
||||
|
||||
@@ -83,7 +83,7 @@ static PyObject *Vector_Zero(VectorObject *self)
|
||||
return (PyObject*)self;
|
||||
}
|
||||
/*----------------------------Vector.normalize() ----------------- */
|
||||
static char Vector_Normalize_doc[] =
|
||||
static char Vector_normalize_doc[] =
|
||||
".. method:: normalize()\n"
|
||||
"\n"
|
||||
" Normalize the vector, making the length of the vector always 1.0.\n"
|
||||
@@ -93,9 +93,9 @@ static char Vector_Normalize_doc[] =
|
||||
"\n"
|
||||
" .. warning:: Normalizing a vector where all values are zero results in all axis having a nan value (not a number).\n"
|
||||
"\n"
|
||||
" .. note:: Normalize works for vectors of all sizes, however 4D Vectors w axis is left untouched.\n";
|
||||
|
||||
static PyObject *Vector_Normalize(VectorObject *self)
|
||||
" .. note:: Normalize works for vectors of all sizes, however 4D Vectors w axis is left untouched.\n"
|
||||
;
|
||||
static PyObject *Vector_normalize(VectorObject *self)
|
||||
{
|
||||
int i;
|
||||
float norm = 0.0f;
|
||||
@@ -118,15 +118,15 @@ static PyObject *Vector_Normalize(VectorObject *self)
|
||||
|
||||
|
||||
/*----------------------------Vector.resize2D() ------------------ */
|
||||
static char Vector_Resize2D_doc[] =
|
||||
static char Vector_resize2D_doc[] =
|
||||
".. method:: resize2D()\n"
|
||||
"\n"
|
||||
" Resize the vector to 2D (x, y).\n"
|
||||
"\n"
|
||||
" :return: an instance of itself\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Resize2D(VectorObject *self)
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
static PyObject *Vector_resize2D(VectorObject *self)
|
||||
{
|
||||
if(self->wrapped==Py_WRAP) {
|
||||
PyErr_SetString(PyExc_TypeError, "vector.resize2D(): cannot resize wrapped data - only python vectors");
|
||||
@@ -148,15 +148,15 @@ static PyObject *Vector_Resize2D(VectorObject *self)
|
||||
return (PyObject*)self;
|
||||
}
|
||||
/*----------------------------Vector.resize3D() ------------------ */
|
||||
static char Vector_Resize3D_doc[] =
|
||||
static char Vector_resize3D_doc[] =
|
||||
".. method:: resize3D()\n"
|
||||
"\n"
|
||||
" Resize the vector to 3D (x, y, z).\n"
|
||||
"\n"
|
||||
" :return: an instance of itself\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Resize3D(VectorObject *self)
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
static PyObject *Vector_resize3D(VectorObject *self)
|
||||
{
|
||||
if (self->wrapped==Py_WRAP) {
|
||||
PyErr_SetString(PyExc_TypeError, "vector.resize3D(): cannot resize wrapped data - only python vectors");
|
||||
@@ -181,15 +181,15 @@ static PyObject *Vector_Resize3D(VectorObject *self)
|
||||
return (PyObject*)self;
|
||||
}
|
||||
/*----------------------------Vector.resize4D() ------------------ */
|
||||
static char Vector_Resize4D_doc[] =
|
||||
static char Vector_resize4D_doc[] =
|
||||
".. method:: resize4D()\n"
|
||||
"\n"
|
||||
" Resize the vector to 4D (x, y, z, w).\n"
|
||||
"\n"
|
||||
" :return: an instance of itself\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Resize4D(VectorObject *self)
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
static PyObject *Vector_resize4D(VectorObject *self)
|
||||
{
|
||||
if(self->wrapped==Py_WRAP) {
|
||||
PyErr_SetString(PyExc_TypeError, "vector.resize4D(): cannot resize wrapped data - only python vectors");
|
||||
@@ -217,7 +217,7 @@ static PyObject *Vector_Resize4D(VectorObject *self)
|
||||
}
|
||||
|
||||
/*----------------------------Vector.toTuple() ------------------ */
|
||||
static char Vector_ToTuple_doc[] =
|
||||
static char Vector_to_tuple_doc[] =
|
||||
".. method:: to_tuple(precision=-1)\n"
|
||||
"\n"
|
||||
" Return this vector as a tuple with.\n"
|
||||
@@ -225,10 +225,10 @@ static char Vector_ToTuple_doc[] =
|
||||
" :arg precision: The number to round the value to in [-1, 21].\n"
|
||||
" :type precision: int\n"
|
||||
" :return: the values of the vector rounded by *precision*\n"
|
||||
" :rtype: tuple\n";
|
||||
|
||||
" :rtype: tuple\n"
|
||||
;
|
||||
/* note: BaseMath_ReadCallback must be called beforehand */
|
||||
static PyObject *Vector_ToTupleExt(VectorObject *self, int ndigits)
|
||||
static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits)
|
||||
{
|
||||
PyObject *ret;
|
||||
int i;
|
||||
@@ -249,7 +249,7 @@ static PyObject *Vector_ToTupleExt(VectorObject *self, int ndigits)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject *Vector_ToTuple(VectorObject *self, PyObject *args)
|
||||
static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args)
|
||||
{
|
||||
int ndigits= 0;
|
||||
|
||||
@@ -267,11 +267,11 @@ static PyObject *Vector_ToTuple(VectorObject *self, PyObject *args)
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
return Vector_ToTupleExt(self, ndigits);
|
||||
return Vector_to_tuple_ext(self, ndigits);
|
||||
}
|
||||
|
||||
/*----------------------------Vector.toTrackQuat(track, up) ---------------------- */
|
||||
static char Vector_ToTrackQuat_doc[] =
|
||||
static char Vector_to_track_quat_doc[] =
|
||||
".. method:: to_track_quat(track, up)\n"
|
||||
"\n"
|
||||
" Return a quaternion rotation from the vector and the track and up axis.\n"
|
||||
@@ -281,12 +281,12 @@ static char Vector_ToTrackQuat_doc[] =
|
||||
" :arg up: Up axis in ['X', 'Y', 'Z'].\n"
|
||||
" :type up: string\n"
|
||||
" :return: rotation from the vector and the track and up axis.\n"
|
||||
" :rtype: :class:`Quaternion`\n";
|
||||
|
||||
static PyObject *Vector_ToTrackQuat(VectorObject *self, PyObject *args )
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
;
|
||||
static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args )
|
||||
{
|
||||
float vec[3], quat[4];
|
||||
char *strack, *sup;
|
||||
const char *strack, *sup;
|
||||
short track = 2, up = 1;
|
||||
|
||||
if(!PyArg_ParseTuple( args, "|ss:to_track_quat", &strack, &sup))
|
||||
@@ -389,7 +389,7 @@ static PyObject *Vector_ToTrackQuat(VectorObject *self, PyObject *args )
|
||||
return a reflected vector on the mirror normal
|
||||
vec - ((2 * DotVecs(vec, mirror)) * mirror)
|
||||
*/
|
||||
static char Vector_Reflect_doc[] =
|
||||
static char Vector_reflect_doc[] =
|
||||
".. method:: reflect(mirror)\n"
|
||||
"\n"
|
||||
" Return the reflection vector from the *mirror* argument.\n"
|
||||
@@ -397,38 +397,38 @@ static char Vector_Reflect_doc[] =
|
||||
" :arg mirror: This vector could be a normal from the reflecting surface.\n"
|
||||
" :type mirror: :class:`Vector`\n"
|
||||
" :return: The reflected vector matching the size of this vector.\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Reflect(VectorObject *self, VectorObject *value )
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
static PyObject *Vector_reflect(VectorObject *self, PyObject *value)
|
||||
{
|
||||
int value_size;
|
||||
float mirror[3], vec[3];
|
||||
float reflect[3] = {0.0f, 0.0f, 0.0f};
|
||||
float reflect[3] = {0.0f};
|
||||
float tvec[MAX_DIMENSIONS];
|
||||
|
||||
if (!VectorObject_Check(value)) {
|
||||
PyErr_SetString(PyExc_TypeError, "vec.reflect(value): expected a vector argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
mirror[0] = value->vec[0];
|
||||
mirror[1] = value->vec[1];
|
||||
if (value->size > 2) mirror[2] = value->vec[2];
|
||||
if((value_size= mathutils_array_parse(tvec, 2, 4, value, "vector.reflect(other), invalid 'other' arg")) == -1)
|
||||
return NULL;
|
||||
|
||||
mirror[0] = tvec[0];
|
||||
mirror[1] = tvec[1];
|
||||
if (value_size > 2) mirror[2] = tvec[2];
|
||||
else mirror[2] = 0.0;
|
||||
|
||||
vec[0] = self->vec[0];
|
||||
vec[1] = self->vec[1];
|
||||
if (self->size > 2) vec[2] = self->vec[2];
|
||||
else vec[2] = 0.0;
|
||||
|
||||
|
||||
normalize_v3(mirror);
|
||||
reflect_v3_v3v3(reflect, vec, mirror);
|
||||
|
||||
|
||||
return newVectorObject(reflect, self->size, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
|
||||
static char Vector_Cross_doc[] =
|
||||
static char Vector_cross_doc[] =
|
||||
".. method:: cross(other)\n"
|
||||
"\n"
|
||||
" Return the cross product of this vector and another.\n"
|
||||
@@ -438,31 +438,25 @@ static char Vector_Cross_doc[] =
|
||||
" :return: The cross product.\n"
|
||||
" :rtype: :class:`Vector`\n"
|
||||
"\n"
|
||||
" .. note:: both vectors must be 3D\n";
|
||||
|
||||
static PyObject *Vector_Cross(VectorObject *self, VectorObject *value )
|
||||
" .. note:: both vectors must be 3D\n"
|
||||
;
|
||||
static PyObject *Vector_cross(VectorObject *self, PyObject *value)
|
||||
{
|
||||
VectorObject *vecCross = NULL;
|
||||
VectorObject *ret;
|
||||
float tvec[MAX_DIMENSIONS];
|
||||
|
||||
if (!VectorObject_Check(value)) {
|
||||
PyErr_SetString(PyExc_TypeError, "vec.cross(value): expected a vector argument");
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->size != 3 || value->size != 3) {
|
||||
PyErr_SetString(PyExc_AttributeError, "vec.cross(value): expects both vectors to be 3D");
|
||||
|
||||
if(mathutils_array_parse(tvec, self->size, self->size, value, "vector.cross(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
return NULL;
|
||||
|
||||
vecCross = (VectorObject *)newVectorObject(NULL, 3, Py_NEW, Py_TYPE(self));
|
||||
cross_v3_v3v3(vecCross->vec, self->vec, value->vec);
|
||||
return (PyObject *)vecCross;
|
||||
|
||||
ret= (VectorObject *)newVectorObject(NULL, 3, Py_NEW, Py_TYPE(self));
|
||||
cross_v3_v3v3(ret->vec, self->vec, tvec);
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
|
||||
static char Vector_Dot_doc[] =
|
||||
static char Vector_dot_doc[] =
|
||||
".. method:: dot(other)\n"
|
||||
"\n"
|
||||
" Return the dot product of this vector and another.\n"
|
||||
@@ -470,29 +464,24 @@ static char Vector_Dot_doc[] =
|
||||
" :arg other: The other vector to perform the dot product with.\n"
|
||||
" :type other: :class:`Vector`\n"
|
||||
" :return: The dot product.\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Dot(VectorObject *self, VectorObject *value )
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
static PyObject *Vector_dot(VectorObject *self, PyObject *value)
|
||||
{
|
||||
float tvec[MAX_DIMENSIONS];
|
||||
double dot = 0.0;
|
||||
int x;
|
||||
|
||||
if (!VectorObject_Check(value)) {
|
||||
PyErr_SetString(PyExc_TypeError, "vec.dot(value): expected a vector argument");
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->size != value->size) {
|
||||
PyErr_SetString(PyExc_AttributeError, "vec.dot(value): expects both vectors to have the same size");
|
||||
|
||||
if(mathutils_array_parse(tvec, self->size, self->size, value, "vector.dot(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
return NULL;
|
||||
|
||||
|
||||
for(x = 0; x < self->size; x++) {
|
||||
dot += self->vec[x] * value->vec[x];
|
||||
dot += self->vec[x] * tvec[x];
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(dot);
|
||||
}
|
||||
|
||||
@@ -508,36 +497,29 @@ static char Vector_angle_doc[] =
|
||||
" :return: angle in radians or fallback when given\n"
|
||||
" :rtype: float\n"
|
||||
"\n"
|
||||
" .. note:: Zero length vectors raise an :exc:`AttributeError`.\n";
|
||||
" .. note:: Zero length vectors raise an :exc:`AttributeError`.\n"
|
||||
;
|
||||
static PyObject *Vector_angle(VectorObject *self, PyObject *args)
|
||||
{
|
||||
VectorObject *value;
|
||||
double dot = 0.0f, angleRads, test_v1 = 0.0f, test_v2 = 0.0f;
|
||||
int x, size;
|
||||
const int size= self->size;
|
||||
float tvec[MAX_DIMENSIONS];
|
||||
PyObject *value;
|
||||
double dot = 0.0f, test_v1 = 0.0f, test_v2 = 0.0f;
|
||||
int x;
|
||||
PyObject *fallback= NULL;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!|O:angle", &vector_Type, &value, &fallback))
|
||||
if(!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback))
|
||||
return NULL;
|
||||
|
||||
if (!VectorObject_Check(value)) {
|
||||
PyErr_SetString(PyExc_TypeError, "vec.angle(value): expected a vector argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->size != value->size) {
|
||||
PyErr_SetString(PyExc_AttributeError, "vec.angle(value): expects both vectors to have the same size");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
//since size is the same
|
||||
size = self->size;
|
||||
if(mathutils_array_parse(tvec, size, size, value, "vector.angle(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
for(x = 0; x < size; x++) {
|
||||
test_v1 += self->vec[x] * self->vec[x];
|
||||
test_v2 += value->vec[x] * value->vec[x];
|
||||
test_v2 += tvec[x] * tvec[x];
|
||||
}
|
||||
if (!test_v1 || !test_v2){
|
||||
/* avoid exception */
|
||||
@@ -552,17 +534,15 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
//dot product
|
||||
for(x = 0; x < size; x++) {
|
||||
dot += self->vec[x] * value->vec[x];
|
||||
for(x = 0; x < self->size; x++) {
|
||||
dot += self->vec[x] * tvec[x];
|
||||
}
|
||||
dot /= (sqrt(test_v1) * sqrt(test_v2));
|
||||
|
||||
angleRads = (double)saacos(dot);
|
||||
|
||||
return PyFloat_FromDouble(angleRads);
|
||||
return PyFloat_FromDouble(saacos(dot));
|
||||
}
|
||||
|
||||
static char Vector_Difference_doc[] =
|
||||
static char Vector_difference_doc[] =
|
||||
".. function:: difference(other)\n"
|
||||
"\n"
|
||||
" Returns a quaternion representing the rotational difference between this vector and another.\n"
|
||||
@@ -572,34 +552,32 @@ static char Vector_Difference_doc[] =
|
||||
" :return: the rotational difference between the two vectors.\n"
|
||||
" :rtype: :class:`Quaternion`\n"
|
||||
"\n"
|
||||
" .. note:: 2D vectors raise an :exc:`AttributeError`.\n";
|
||||
|
||||
static PyObject *Vector_Difference(VectorObject *self, VectorObject *value )
|
||||
" .. note:: 2D vectors raise an :exc:`AttributeError`.\n"
|
||||
;
|
||||
static PyObject *Vector_difference(VectorObject *self, PyObject *value)
|
||||
{
|
||||
float quat[4], vec_a[3], vec_b[3];
|
||||
|
||||
if (!VectorObject_Check(value)) {
|
||||
PyErr_SetString(PyExc_TypeError, "vec.difference(value): expected a vector argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->size < 3 || value->size < 3) {
|
||||
if(self->size < 3) {
|
||||
PyErr_SetString(PyExc_AttributeError, "vec.difference(value): expects both vectors to be size 3 or 4");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "vector.difference(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
normalize_v3_v3(vec_a, self->vec);
|
||||
normalize_v3_v3(vec_b, value->vec);
|
||||
normalize_v3(vec_b);
|
||||
|
||||
rotation_between_vecs_to_quat(quat, vec_a, vec_b);
|
||||
|
||||
return newQuaternionObject(quat, Py_NEW, NULL);
|
||||
}
|
||||
|
||||
static char Vector_Project_doc[] =
|
||||
static char Vector_project_doc[] =
|
||||
".. function:: project(other)\n"
|
||||
"\n"
|
||||
" Return the projection of this vector onto the *other*.\n"
|
||||
@@ -607,45 +585,39 @@ static char Vector_Project_doc[] =
|
||||
" :arg other: second vector.\n"
|
||||
" :type other: :class:`Vector`\n"
|
||||
" :return: the parallel projection vector\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Project(VectorObject *self, VectorObject *value)
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
static PyObject *Vector_project(VectorObject *self, PyObject *value)
|
||||
{
|
||||
float vec[4];
|
||||
const int size= self->size;
|
||||
float tvec[MAX_DIMENSIONS];
|
||||
float vec[MAX_DIMENSIONS];
|
||||
double dot = 0.0f, dot2 = 0.0f;
|
||||
int x, size;
|
||||
int x;
|
||||
|
||||
if (!VectorObject_Check(value)) {
|
||||
PyErr_SetString(PyExc_TypeError, "vec.project(value): expected a vector argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->size != value->size) {
|
||||
PyErr_SetString(PyExc_AttributeError, "vec.project(value): expects both vectors to have the same size");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value))
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
if(mathutils_array_parse(tvec, size, size, value, "vector.project(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
//since they are the same size
|
||||
size = self->size;
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
//get dot products
|
||||
for(x = 0; x < size; x++) {
|
||||
dot += self->vec[x] * value->vec[x];
|
||||
dot2 += value->vec[x] * value->vec[x];
|
||||
dot += self->vec[x] * tvec[x];
|
||||
dot2 += tvec[x] * tvec[x];
|
||||
}
|
||||
//projection
|
||||
dot /= dot2;
|
||||
for(x = 0; x < size; x++) {
|
||||
vec[x] = (float)(dot * value->vec[x]);
|
||||
vec[x] = (float)(dot * tvec[x]);
|
||||
}
|
||||
return newVectorObject(vec, size, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
|
||||
static char Vector_Lerp_doc[] =
|
||||
static char Vector_lerp_doc[] =
|
||||
".. function:: lerp(other, factor)\n"
|
||||
"\n"
|
||||
" Returns the interpolation of two vectors.\n"
|
||||
@@ -655,35 +627,35 @@ static char Vector_Lerp_doc[] =
|
||||
" :arg factor: The interpolation value in [0.0, 1.0].\n"
|
||||
" :type factor: float\n"
|
||||
" :return: The interpolated rotation.\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Lerp(VectorObject *self, PyObject *args)
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
static PyObject *Vector_lerp(VectorObject *self, PyObject *args)
|
||||
{
|
||||
VectorObject *vec2 = NULL;
|
||||
float fac, ifac, vec[4];
|
||||
const int size= self->size;
|
||||
PyObject *value= NULL;
|
||||
float fac, ifac;
|
||||
float tvec[MAX_DIMENSIONS], vec[MAX_DIMENSIONS];
|
||||
int x;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!f:lerp", &vector_Type, &vec2, &fac))
|
||||
if(!PyArg_ParseTuple(args, "Of:lerp", &value, &fac))
|
||||
return NULL;
|
||||
|
||||
if(self->size != vec2->size) {
|
||||
PyErr_SetString(PyExc_AttributeError, "vector.lerp(): expects both vector objects to have the same size");
|
||||
if(mathutils_array_parse(tvec, size, size, value, "vector.lerp(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(vec2))
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
ifac= 1.0 - fac;
|
||||
|
||||
for(x = 0; x < self->size; x++) {
|
||||
vec[x] = (ifac * self->vec[x]) + (fac * vec2->vec[x]);
|
||||
for(x = 0; x < size; x++) {
|
||||
vec[x] = (ifac * self->vec[x]) + (fac * tvec[x]);
|
||||
}
|
||||
return newVectorObject(vec, self->size, Py_NEW, Py_TYPE(self));
|
||||
return newVectorObject(vec, size, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
|
||||
/*---------------------------- Vector.rotate(angle, axis) ----------------------*/
|
||||
static char Vector_Rotate_doc[] =
|
||||
static char Vector_rotate_doc[] =
|
||||
".. function:: rotate(axis, angle)\n"
|
||||
"\n"
|
||||
" Return vector rotated around axis by angle.\n"
|
||||
@@ -693,27 +665,30 @@ static char Vector_Rotate_doc[] =
|
||||
" :arg angle: angle in radians.\n"
|
||||
" :type angle: float\n"
|
||||
" :return: an instance of itself\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Rotate(VectorObject *self, PyObject *args)
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
static PyObject *Vector_rotate(VectorObject *self, PyObject *args)
|
||||
{
|
||||
VectorObject *axis_vec = NULL;
|
||||
float angle, vec[3];
|
||||
PyObject *value;
|
||||
float angle, vec[3], tvec[3];
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O!f", &vector_Type, &axis_vec, &angle)){
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Of:rotate", &value, &angle)){
|
||||
PyErr_SetString(PyExc_TypeError, "vec.rotate(axis, angle): expected 3D axis (Vector) and angle (float)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->size != 3 || axis_vec->size != 3) {
|
||||
if(self->size != 3) {
|
||||
PyErr_SetString(PyExc_AttributeError, "vec.rotate(axis, angle): expects both vectors to be 3D");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(axis_vec))
|
||||
if(mathutils_array_parse(tvec, 3, 3, value, "vector.rotate(axis, angle), invalid 'axis' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
rotate_v3_v3v3fl(vec, self->vec, axis_vec->vec, angle);
|
||||
rotate_v3_v3v3fl(vec, self->vec, tvec, angle);
|
||||
|
||||
copy_v3_v3(self->vec, vec);
|
||||
|
||||
@@ -730,8 +705,8 @@ static char Vector_copy_doc[] =
|
||||
" :return: A copy of the vector.\n"
|
||||
" :rtype: :class:`Vector`\n"
|
||||
"\n"
|
||||
" .. note:: use this to get a copy of a wrapped vector with no reference to the original data.\n";
|
||||
|
||||
" .. note:: use this to get a copy of a wrapped vector with no reference to the original data.\n"
|
||||
;
|
||||
static PyObject *Vector_copy(VectorObject *self)
|
||||
{
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
@@ -749,7 +724,7 @@ static PyObject *Vector_repr(VectorObject *self)
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
tuple= Vector_ToTupleExt(self, -1);
|
||||
tuple= Vector_to_tuple_ext(self, -1);
|
||||
ret= PyUnicode_FromFormat("Vector(%R)", tuple);
|
||||
Py_DECREF(tuple);
|
||||
return ret;
|
||||
@@ -839,7 +814,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end,
|
||||
begin = MIN2(begin,end);
|
||||
|
||||
size = (end - begin);
|
||||
if(mathutils_array_parse(vec, size, size, seq, "vector[begin:end] = [...]:") == -1)
|
||||
if(mathutils_array_parse(vec, size, size, seq, "vector[begin:end] = [...]") == -1)
|
||||
return -1;
|
||||
|
||||
/*parsed well - now set in vector*/
|
||||
@@ -1444,12 +1419,12 @@ static PyNumberMethods Vector_NumMethods = {
|
||||
* vector axis, vector.x/y/z/w
|
||||
*/
|
||||
|
||||
static PyObject *Vector_getAxis(VectorObject *self, void *type )
|
||||
static PyObject *Vector_getAxis(VectorObject *self, void *type)
|
||||
{
|
||||
return Vector_item(self, GET_INT_FROM_POINTER(type));
|
||||
}
|
||||
|
||||
static int Vector_setAxis(VectorObject *self, PyObject * value, void * type )
|
||||
static int Vector_setAxis(VectorObject *self, PyObject * value, void *type)
|
||||
{
|
||||
return Vector_ass_item(self, GET_INT_FROM_POINTER(type), value);
|
||||
}
|
||||
@@ -2058,15 +2033,15 @@ static int row_vector_multiplication(float rvec[4], VectorObject* vec, MatrixObj
|
||||
#endif
|
||||
|
||||
/*----------------------------Vector.negate() -------------------- */
|
||||
static char Vector_Negate_doc[] =
|
||||
static char Vector_negate_doc[] =
|
||||
".. method:: negate()\n"
|
||||
"\n"
|
||||
" Set all values to their negative.\n"
|
||||
"\n"
|
||||
" :return: an instance of itself\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Negate(VectorObject *self)
|
||||
" :rtype: :class:`Vector`\n"
|
||||
;
|
||||
static PyObject *Vector_negate(VectorObject *self)
|
||||
{
|
||||
int i;
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
@@ -2082,22 +2057,22 @@ static PyObject *Vector_Negate(VectorObject *self)
|
||||
}
|
||||
|
||||
static struct PyMethodDef Vector_methods[] = {
|
||||
{"zero", (PyCFunction) Vector_Zero, METH_NOARGS, Vector_Zero_doc},
|
||||
{"normalize", (PyCFunction) Vector_Normalize, METH_NOARGS, Vector_Normalize_doc},
|
||||
{"negate", (PyCFunction) Vector_Negate, METH_NOARGS, Vector_Negate_doc},
|
||||
{"resize2D", (PyCFunction) Vector_Resize2D, METH_NOARGS, Vector_Resize2D_doc},
|
||||
{"resize3D", (PyCFunction) Vector_Resize3D, METH_NOARGS, Vector_Resize3D_doc},
|
||||
{"resize4D", (PyCFunction) Vector_Resize4D, METH_NOARGS, Vector_Resize4D_doc},
|
||||
{"to_tuple", (PyCFunction) Vector_ToTuple, METH_VARARGS, Vector_ToTuple_doc},
|
||||
{"to_track_quat", ( PyCFunction ) Vector_ToTrackQuat, METH_VARARGS, Vector_ToTrackQuat_doc},
|
||||
{"reflect", ( PyCFunction ) Vector_Reflect, METH_O, Vector_Reflect_doc},
|
||||
{"cross", ( PyCFunction ) Vector_Cross, METH_O, Vector_Cross_doc},
|
||||
{"dot", ( PyCFunction ) Vector_Dot, METH_O, Vector_Dot_doc},
|
||||
{"angle", ( PyCFunction ) Vector_angle, METH_VARARGS, Vector_angle_doc},
|
||||
{"difference", ( PyCFunction ) Vector_Difference, METH_O, Vector_Difference_doc},
|
||||
{"project", ( PyCFunction ) Vector_Project, METH_O, Vector_Project_doc},
|
||||
{"lerp", ( PyCFunction ) Vector_Lerp, METH_VARARGS, Vector_Lerp_doc},
|
||||
{"rotate", ( PyCFunction ) Vector_Rotate, METH_VARARGS, Vector_Rotate_doc},
|
||||
{"zero", (PyCFunction) Vector_zero, METH_NOARGS, Vector_zero_doc},
|
||||
{"normalize", (PyCFunction) Vector_normalize, METH_NOARGS, Vector_normalize_doc},
|
||||
{"negate", (PyCFunction) Vector_negate, METH_NOARGS, Vector_negate_doc},
|
||||
{"resize2D", (PyCFunction) Vector_resize2D, METH_NOARGS, Vector_resize2D_doc},
|
||||
{"resize3D", (PyCFunction) Vector_resize3D, METH_NOARGS, Vector_resize3D_doc},
|
||||
{"resize4D", (PyCFunction) Vector_resize4D, METH_NOARGS, Vector_resize4D_doc},
|
||||
{"to_tuple", (PyCFunction) Vector_to_tuple, METH_VARARGS, Vector_to_tuple_doc},
|
||||
{"to_track_quat", (PyCFunction) Vector_to_track_quat, METH_VARARGS, Vector_to_track_quat_doc},
|
||||
{"reflect", (PyCFunction) Vector_reflect, METH_O, Vector_reflect_doc},
|
||||
{"cross", (PyCFunction) Vector_cross, METH_O, Vector_cross_doc},
|
||||
{"dot", (PyCFunction) Vector_dot, METH_O, Vector_dot_doc},
|
||||
{"angle", (PyCFunction) Vector_angle, METH_VARARGS, Vector_angle_doc},
|
||||
{"difference", (PyCFunction) Vector_difference, METH_O, Vector_difference_doc},
|
||||
{"project", (PyCFunction) Vector_project, METH_O, Vector_project_doc},
|
||||
{"lerp", (PyCFunction) Vector_lerp, METH_VARARGS, Vector_lerp_doc},
|
||||
{"rotate", (PyCFunction) Vector_rotate, METH_VARARGS, Vector_rotate_doc},
|
||||
{"copy", (PyCFunction) Vector_copy, METH_NOARGS, Vector_copy_doc},
|
||||
{"__copy__", (PyCFunction) Vector_copy, METH_NOARGS, NULL},
|
||||
{NULL, NULL, 0, NULL}
|
||||
@@ -2111,8 +2086,8 @@ static struct PyMethodDef Vector_methods[] = {
|
||||
*/
|
||||
|
||||
static char vector_doc[] =
|
||||
"This object gives access to Vectors in Blender.";
|
||||
|
||||
"This object gives access to Vectors in Blender."
|
||||
;
|
||||
PyTypeObject vector_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/* For printing, in format "<module>.<name>" */
|
||||
|
||||
Reference in New Issue
Block a user