28 #include "../generic/py_capi_utils.h"
30 #ifndef MATH_STANDALONE
39 #define MAX_DIMENSIONS 4
44 #define SWIZZLE_BITS_PER_AXIS 3
45 #define SWIZZLE_VALID_AXIS 0x4
46 #define SWIZZLE_AXIS 0x3
59 static PyObject *
Vector_new(PyTypeObject *
type, PyObject *args, PyObject *kwds)
64 if (kwds && PyDict_Size(kwds)) {
65 PyErr_SetString(PyExc_TypeError,
67 "takes no keyword args");
71 switch (PyTuple_GET_SIZE(args)) {
73 vec = PyMem_Malloc(
size *
sizeof(
float));
76 PyErr_SetString(PyExc_MemoryError,
78 "problem allocating pointer space");
86 &vec, 2, PyTuple_GET_ITEM(args, 0),
"mathutils.Vector()")) == -1) {
91 PyErr_SetString(PyExc_TypeError,
92 "mathutils.Vector(): "
93 "more than a single arg given");
104 Py_DECREF(ret_dummy);
105 return (PyObject *)
ret;
114 ".. classmethod:: Fill(size, fill=0.0)\n"
116 " Create a vector of length size with all values set to fill.\n"
118 " :arg size: The length of the vector to be created.\n"
120 " :arg fill: The value used to fill the vector.\n"
121 " :type fill: float\n");
128 if (!PyArg_ParseTuple(args,
"i|f:Vector.Fill", &
size, &fill)) {
133 PyErr_SetString(PyExc_RuntimeError,
"Vector(): invalid size");
137 vec = PyMem_Malloc(
size *
sizeof(
float));
140 PyErr_SetString(PyExc_MemoryError,
142 "problem allocating pointer space");
152 ".. classmethod:: Range(start=0, stop, step=1)\n"
154 " Create a filled with a range of values.\n"
156 " :arg start: The start of the range used to fill the vector.\n"
157 " :type start: int\n"
158 " :arg stop: The end of the range used to fill the vector.\n"
160 " :arg step: The step between successive values in the vector.\n"
161 " :type step: int\n");
169 if (!PyArg_ParseTuple(args,
"i|ii:Vector.Range", &start, &stop, &step)) {
173 switch (PyTuple_GET_SIZE(args)) {
180 PyErr_SetString(PyExc_RuntimeError,
181 "Start value is larger "
182 "than the stop value");
190 PyErr_SetString(PyExc_RuntimeError,
191 "Start value is larger "
192 "than the stop value");
196 size = (stop - start);
198 if ((
size % step) != 0) {
208 PyErr_SetString(PyExc_RuntimeError,
"Vector(): invalid size");
212 vec = PyMem_Malloc(
size *
sizeof(
float));
215 PyErr_SetString(PyExc_MemoryError,
217 "problem allocating pointer space");
227 ".. classmethod:: Linspace(start, stop, size)\n"
229 " Create a vector of the specified size which is filled with linearly spaced "
230 "values between start and stop values.\n"
232 " :arg start: The start of the range used to fill the vector.\n"
233 " :type start: int\n"
234 " :arg stop: The end of the range used to fill the vector.\n"
236 " :arg size: The size of the vector to be created.\n"
237 " :type size: int\n");
242 float start, end, step;
244 if (!PyArg_ParseTuple(args,
"ffi:Vector.Linspace", &start, &end, &
size)) {
249 PyErr_SetString(PyExc_RuntimeError,
"Vector.Linspace(): invalid size");
253 step = (end - start) / (
float)(
size - 1);
255 vec = PyMem_Malloc(
size *
sizeof(
float));
258 PyErr_SetString(PyExc_MemoryError,
259 "Vector.Linspace(): "
260 "problem allocating pointer space");
271 ".. classmethod:: Repeat(vector, size)\n"
273 " Create a vector by repeating the values in vector until the required size is reached.\n"
275 " :arg tuple: The vector to draw values from.\n"
276 " :type tuple: :class:`mathutils.Vector`\n"
277 " :arg size: The size of the vector to be created.\n"
278 " :type size: int\n");
282 float *iter_vec =
NULL;
283 int i,
size, value_size;
286 if (!PyArg_ParseTuple(args,
"Oi:Vector.Repeat", &value, &
size)) {
291 PyErr_SetString(PyExc_RuntimeError,
"Vector.Repeat(): invalid size");
296 &iter_vec, 2, value,
"Vector.Repeat(vector, size), invalid 'vector' arg")) == -1) {
300 if (iter_vec ==
NULL) {
301 PyErr_SetString(PyExc_MemoryError,
303 "problem allocating pointer space");
307 vec = PyMem_Malloc(
size *
sizeof(
float));
310 PyMem_Free(iter_vec);
311 PyErr_SetString(PyExc_MemoryError,
313 "problem allocating pointer space");
319 vec[i] = iter_vec[i % value_size];
323 PyMem_Free(iter_vec);
330 ".. method:: zero()\n"
332 " Set all values to zero.\n");
349 ".. method:: normalize()\n"
351 " Normalize the vector, making the length of the vector always 1.0.\n"
353 " .. warning:: Normalizing a vector where all values are zero has no effect.\n"
355 " .. note:: Normalize works for vectors of all sizes,\n"
356 " however 4D Vectors w axis is left untouched.\n");
359 const int size = (
self->size == 4 ? 3 :
self->size);
370 ".. method:: normalized()\n"
372 " Return a new, normalized vector.\n"
374 " :return: a normalized copy of the vector\n"
375 " :rtype: :class:`Vector`\n");
382 ".. method:: resize(size=3)\n"
384 " Resize the vector to have size number of elements.\n");
390 PyErr_SetString(PyExc_TypeError,
392 "cannot resize wrapped data - only python vectors");
396 PyErr_SetString(PyExc_TypeError,
398 "cannot resize a vector that has an owner");
402 if ((
size = PyC_Long_AsI32(value)) == -1) {
403 PyErr_SetString(PyExc_TypeError,
404 "Vector.resize(size): "
405 "expected size argument to be an integer");
410 PyErr_SetString(PyExc_RuntimeError,
"Vector.resize(): invalid size");
414 self->vec = PyMem_Realloc(
self->vec, (
size *
sizeof(
float)));
416 PyErr_SetString(PyExc_MemoryError,
418 "problem allocating pointer space");
432 ".. method:: resized(size=3)\n"
434 " Return a resized copy of the vector with size number of elements.\n"
436 " :return: a new vector\n"
437 " :rtype: :class:`Vector`\n");
443 if ((
size = PyLong_AsLong(value)) == -1) {
448 PyErr_SetString(PyExc_RuntimeError,
"Vector.resized(): invalid size");
452 vec = PyMem_Malloc(
size *
sizeof(
float));
455 PyErr_SetString(PyExc_MemoryError,
457 "problem allocating pointer space");
462 memcpy(vec,
self->vec,
self->size *
sizeof(
float));
468 ".. method:: resize_2d()\n"
470 " Resize the vector to 2D (x, y).\n");
474 PyErr_SetString(PyExc_TypeError,
475 "Vector.resize_2d(): "
476 "cannot resize wrapped data - only python vectors");
480 PyErr_SetString(PyExc_TypeError,
481 "Vector.resize_2d(): "
482 "cannot resize a vector that has an owner");
486 self->vec = PyMem_Realloc(
self->vec,
sizeof(
float[2]));
488 PyErr_SetString(PyExc_MemoryError,
489 "Vector.resize_2d(): "
490 "problem allocating pointer space");
499 ".. method:: resize_3d()\n"
501 " Resize the vector to 3D (x, y, z).\n");
505 PyErr_SetString(PyExc_TypeError,
506 "Vector.resize_3d(): "
507 "cannot resize wrapped data - only python vectors");
511 PyErr_SetString(PyExc_TypeError,
512 "Vector.resize_3d(): "
513 "cannot resize a vector that has an owner");
517 self->vec = PyMem_Realloc(
self->vec,
sizeof(
float[3]));
519 PyErr_SetString(PyExc_MemoryError,
520 "Vector.resize_3d(): "
521 "problem allocating pointer space");
525 if (
self->size == 2) {
534 ".. method:: resize_4d()\n"
536 " Resize the vector to 4D (x, y, z, w).\n");
540 PyErr_SetString(PyExc_TypeError,
541 "Vector.resize_4d(): "
542 "cannot resize wrapped data - only python vectors");
546 PyErr_SetString(PyExc_TypeError,
547 "Vector.resize_4d(): "
548 "cannot resize a vector that has an owner");
552 self->vec = PyMem_Realloc(
self->vec,
sizeof(
float[4]));
554 PyErr_SetString(PyExc_MemoryError,
555 "Vector.resize_4d(): "
556 "problem allocating pointer space");
560 if (
self->size == 2) {
564 else if (
self->size == 3) {
571 ".. method:: to_2d()\n"
573 " Return a 2d copy of the vector.\n"
575 " :return: a new vector\n"
576 " :rtype: :class:`Vector`\n");
586 ".. method:: to_3d()\n"
588 " Return a 3d copy of the vector.\n"
590 " :return: a new vector\n"
591 " :rtype: :class:`Vector`\n");
594 float tvec[3] = {0.0f};
600 memcpy(tvec,
self->vec,
sizeof(
float) *
MIN2(
self->size, 3));
604 ".. method:: to_4d()\n"
606 " Return a 4d copy of the vector.\n"
608 " :return: a new vector\n"
609 " :rtype: :class:`Vector`\n");
612 float tvec[4] = {0.0f, 0.0f, 0.0f, 1.0f};
618 memcpy(tvec,
self->vec,
sizeof(
float) *
MIN2(
self->size, 4));
623 ".. method:: to_tuple(precision=-1)\n"
625 " Return this vector as a tuple with.\n"
627 " :arg precision: The number to round the value to in [-1, 21].\n"
628 " :type precision: int\n"
629 " :return: the values of the vector rounded by *precision*\n"
640 for (i = 0; i <
self->size; i++) {
645 for (i = 0; i <
self->size; i++) {
646 PyTuple_SET_ITEM(
ret, i, PyFloat_FromDouble(
self->vec[i]));
657 if (!PyArg_ParseTuple(args,
"|i:to_tuple", &ndigits)) {
661 if (ndigits > 22 || ndigits < 0) {
662 PyErr_SetString(PyExc_ValueError,
663 "Vector.to_tuple(ndigits): "
664 "ndigits must be between 0 and 21");
668 if (PyTuple_GET_SIZE(args) == 0) {
680 ".. method:: to_track_quat(track, up)\n"
682 " Return a quaternion rotation from the vector and the track and up axis.\n"
684 " :arg track: Track axis in ['X', 'Y', 'Z', '-X', '-Y', '-Z'].\n"
685 " :type track: string\n"
686 " :arg up: Up axis in ['X', 'Y', 'Z'].\n"
687 " :type up: string\n"
688 " :return: rotation from the vector and the track and up axis.\n"
689 " :rtype: :class:`Quaternion`\n");
692 float vec[3], quat[4];
693 const char *strack =
NULL;
694 const char *sup =
NULL;
695 short track = 2, up = 1;
697 if (!PyArg_ParseTuple(args,
"|ss:to_track_quat", &strack, &sup)) {
701 if (
self->size != 3) {
702 PyErr_SetString(PyExc_TypeError,
703 "Vector.to_track_quat(): "
704 "only for 3D vectors");
713 const char *axis_err_msg =
"only X, -X, Y, -Y, Z or -Z for track axis";
715 if (strlen(strack) == 2) {
716 if (strack[0] ==
'-') {
728 PyErr_SetString(PyExc_ValueError, axis_err_msg);
733 PyErr_SetString(PyExc_ValueError, axis_err_msg);
737 else if (strlen(strack) == 1) {
750 PyErr_SetString(PyExc_ValueError, axis_err_msg);
755 PyErr_SetString(PyExc_ValueError, axis_err_msg);
761 const char *axis_err_msg =
"only X, Y or Z for up axis";
762 if (strlen(sup) == 1) {
774 PyErr_SetString(PyExc_ValueError, axis_err_msg);
779 PyErr_SetString(PyExc_ValueError, axis_err_msg);
785 PyErr_SetString(PyExc_ValueError,
"Can't have the same axis for track and up");
799 Vector_orthogonal_doc,
800 ".. method:: orthogonal()\n"
802 " Return a perpendicular vector.\n"
804 " :return: a new vector 90 degrees from this vector.\n"
805 " :rtype: :class:`Vector`\n"
807 " .. note:: the axis is undefined, only use when any orthogonal vector is acceptable.\n");
812 if (
self->size > 3) {
813 PyErr_SetString(PyExc_TypeError,
814 "Vector.orthogonal(): "
815 "Vector must be 3D or 2D");
823 if (
self->size == 3) {
840 ".. method:: reflect(mirror)\n"
842 " Return the reflection vector from the *mirror* argument.\n"
844 " :arg mirror: This vector could be a normal from the reflecting surface.\n"
845 " :type mirror: :class:`Vector`\n"
846 " :return: The reflected vector matching the size of this vector.\n"
847 " :rtype: :class:`Vector`\n");
851 float mirror[3], vec[3];
860 tvec, 2, 4, value,
"Vector.reflect(other), invalid 'other' arg")) == -1) {
864 if (
self->size < 2 ||
self->size > 4) {
865 PyErr_SetString(PyExc_ValueError,
"Vector must be 2D, 3D or 4D");
871 mirror[2] = (value_size > 2) ? tvec[2] : 0.0f;
873 vec[0] =
self->vec[0];
874 vec[1] =
self->vec[1];
875 vec[2] = (value_size > 2) ?
self->vec[2] : 0.0f;
884 ".. method:: cross(other)\n"
886 " Return the cross product of this vector and another.\n"
888 " :arg other: The other vector to perform the cross product with.\n"
889 " :type other: :class:`Vector`\n"
890 " :return: The cross product.\n"
891 " :rtype: :class:`Vector` or float when 2D vectors are used\n"
893 " .. note:: both vectors must be 2D or 3D\n");
903 if (
self->size > 3) {
904 PyErr_SetString(PyExc_ValueError,
"Vector must be 2D or 3D");
909 tvec,
self->size,
self->size, value,
"Vector.cross(other), invalid 'other' arg") == -1) {
913 if (
self->size == 3) {
925 ".. method:: dot(other)\n"
927 " Return the dot product of this vector and another.\n"
929 " :arg other: The other vector to perform the dot product with.\n"
930 " :type other: :class:`Vector`\n"
931 " :return: The dot product.\n"
943 &tvec,
self->size, value,
"Vector.dot(other), invalid 'other' arg") == -1) {
954 ".. function:: angle(other, fallback=None)\n"
956 " Return the angle between two vectors.\n"
958 " :arg other: another vector to compare the angle with\n"
959 " :type other: :class:`Vector`\n"
960 " :arg fallback: return this when the angle can't be calculated (zero length vector),\n"
961 " (instead of raising a :exc:`ValueError`).\n"
962 " :type fallback: any\n"
963 " :return: angle in radians or fallback when given\n"
970 double dot = 0.0f, dot_self = 0.0f, dot_other = 0.0f;
972 PyObject *fallback =
NULL;
974 if (!PyArg_ParseTuple(args,
"O|O:angle", &value, &fallback)) {
985 tvec,
self->size,
self->size, value,
"Vector.angle(other), invalid 'other' arg") == -1) {
989 if (
self->size > 4) {
990 PyErr_SetString(PyExc_ValueError,
"Vector must be 2D, 3D or 4D");
995 dot_self += (
double)
self->vec[
x] * (
double)
self->vec[
x];
996 dot_other += (
double)tvec[
x] * (
double)tvec[
x];
1000 if (!dot_self || !dot_other) {
1003 Py_INCREF(fallback);
1007 PyErr_SetString(PyExc_ValueError,
1008 "Vector.angle(other): "
1009 "zero length vectors have no valid angle");
1017 Vector_angle_signed_doc,
1018 ".. function:: angle_signed(other, fallback)\n"
1020 " Return the signed angle between two 2D vectors (clockwise is positive).\n"
1022 " :arg other: another vector to compare the angle with\n"
1023 " :type other: :class:`Vector`\n"
1024 " :arg fallback: return this when the angle can't be calculated (zero length vector),\n"
1025 " (instead of raising a :exc:`ValueError`).\n"
1026 " :type fallback: any\n"
1027 " :return: angle in radians or fallback when given\n"
1028 " :rtype: float\n");
1034 PyObject *fallback =
NULL;
1036 if (!PyArg_ParseTuple(args,
"O|O:angle_signed", &value, &fallback)) {
1045 tvec, 2, 2, value,
"Vector.angle_signed(other), invalid 'other' arg") == -1) {
1049 if (
self->size != 2) {
1050 PyErr_SetString(PyExc_ValueError,
"Vector must be 2D");
1057 Py_INCREF(fallback);
1061 PyErr_SetString(PyExc_ValueError,
1062 "Vector.angle_signed(other): "
1063 "zero length vectors have no valid angle");
1071 ".. function:: rotation_difference(other)\n"
1073 " Returns a quaternion representing the rotational difference between this\n"
1074 " vector and another.\n"
1076 " :arg other: second vector.\n"
1077 " :type other: :class:`Vector`\n"
1078 " :return: the rotational difference between the two vectors.\n"
1079 " :rtype: :class:`Quaternion`\n"
1081 " .. note:: 2D vectors raise an :exc:`AttributeError`.\n");
1084 float quat[4], vec_a[3], vec_b[3];
1086 if (
self->size < 3 ||
self->size > 4) {
1087 PyErr_SetString(PyExc_ValueError,
1088 "vec.difference(value): "
1089 "expects both vectors to be size 3 or 4");
1098 vec_b, 3,
MAX_DIMENSIONS, value,
"Vector.difference(other), invalid 'other' arg") ==
1112 ".. function:: project(other)\n"
1114 " Return the projection of this vector onto the *other*.\n"
1116 " :arg other: second vector.\n"
1117 " :type other: :class:`Vector`\n"
1118 " :return: the parallel projection vector\n"
1119 " :rtype: :class:`Vector`\n");
1122 const int size =
self->size;
1124 double dot = 0.0f, dot2 = 0.0f;
1132 &tvec,
size, value,
"Vector.project(other), invalid 'other' arg") == -1) {
1139 dot2 += (
double)(tvec[
x] * tvec[
x]);
1150 ".. function:: lerp(other, factor)\n"
1152 " Returns the interpolation of two vectors.\n"
1154 " :arg other: value to interpolate with.\n"
1155 " :type other: :class:`Vector`\n"
1156 " :arg factor: The interpolation value in [0.0, 1.0].\n"
1157 " :type factor: float\n"
1158 " :return: The interpolated vector.\n"
1159 " :rtype: :class:`Vector`\n");
1162 const int size =
self->size;
1163 PyObject *value =
NULL;
1167 if (!PyArg_ParseTuple(args,
"Of:lerp", &value, &fac)) {
1186 ".. function:: slerp(other, factor, fallback=None)\n"
1188 " Returns the interpolation of two non-zero vectors (spherical coordinates).\n"
1190 " :arg other: value to interpolate with.\n"
1191 " :type other: :class:`Vector`\n"
1192 " :arg factor: The interpolation value typically in [0.0, 1.0].\n"
1193 " :type factor: float\n"
1194 " :arg fallback: return this when the vector can't be calculated (zero length "
1195 "vector or direct opposites),\n"
1196 " (instead of raising a :exc:`ValueError`).\n"
1197 " :type fallback: any\n"
1198 " :return: The interpolated vector.\n"
1199 " :rtype: :class:`Vector`\n");
1202 const int size =
self->size;
1203 PyObject *value =
NULL;
1204 float fac, cosom,
w[2];
1205 float self_vec[3], other_vec[3], ret_vec[3];
1206 float self_len_sq, other_len_sq;
1208 PyObject *fallback =
NULL;
1210 if (!PyArg_ParseTuple(args,
"Of|O:slerp", &value, &fac, &fallback)) {
1218 if (
self->size > 3) {
1219 PyErr_SetString(PyExc_ValueError,
"Vector must be 2D or 3D");
1224 other_vec,
size,
size, value,
"Vector.slerp(other), invalid 'other' arg") == -1) {
1232 if (
UNLIKELY((self_len_sq < FLT_EPSILON) || (other_len_sq < FLT_EPSILON))) {
1235 Py_INCREF(fallback);
1239 PyErr_SetString(PyExc_ValueError,
1241 "zero length vectors unsupported");
1249 if (
UNLIKELY(cosom < (-1.0f + FLT_EPSILON))) {
1252 Py_INCREF(fallback);
1256 PyErr_SetString(PyExc_ValueError,
1258 "opposite vectors unsupported");
1265 ret_vec[
x] = (
w[0] * self_vec[
x]) + (
w[1] * other_vec[
x]);
1273 ".. function:: rotate(other)\n"
1275 " Rotate the vector by a rotation value.\n"
1277 " .. note:: 2D vectors are a special case that can only be rotated by a 2x2 matrix.\n"
1279 " :arg other: rotation component of mathutils value\n"
1280 " :type other: :class:`Euler`, :class:`Quaternion` or :class:`Matrix`\n");
1287 if (
self->size == 2) {
1289 float other_rmat[2][2];
1299 float other_rmat[3][3];
1313 ".. function:: copy()\n"
1315 " Returns a copy of this vector.\n"
1317 " :return: A copy of the vector.\n"
1318 " :rtype: :class:`Vector`\n"
1320 " .. note:: use this to get a copy of a wrapped vector with\n"
1321 " no reference to the original data.\n");
1340 PyObject *
ret, *tuple;
1347 ret = PyUnicode_FromFormat(
"Vector(%R)", tuple);
1352 #ifndef MATH_STANDALONE
1367 for (i = 0; i <
self->size; i++) {
1390 if (i < 0 || i >=
self->size) {
1392 PyErr_Format(PyExc_AttributeError,
1393 "Vector.%c: unavailable on %dd vector",
1394 *(((
const char *)
"xyzw") + i),
1398 PyErr_SetString(PyExc_IndexError,
"vector[index]: out of range");
1407 return PyFloat_FromDouble(
self->vec[i]);
1423 if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
1425 PyErr_SetString(PyExc_TypeError,
1426 "vector[index] = x: "
1427 "assigned value not a number");
1435 if (i < 0 || i >=
self->size) {
1437 PyErr_Format(PyExc_AttributeError,
1438 "Vector.%c = x: unavailable on %dd vector",
1439 *(((
const char *)
"xyzw") + i),
1443 PyErr_SetString(PyExc_IndexError,
1444 "vector[index] = x: "
1445 "assignment index out of range");
1449 self->vec[i] = scalar;
1474 end =
self->size + end + 1;
1477 begin =
MIN2(begin, end);
1479 tuple = PyTuple_New(end - begin);
1481 PyTuple_SET_ITEM(tuple,
count - begin, PyFloat_FromDouble(
self->vec[
count]));
1498 begin =
MIN2(begin, end);
1500 size = (end - begin);
1506 PyErr_SetString(PyExc_MemoryError,
1508 "problem allocating pointer space");
1513 memcpy(
self->vec + begin, vec,
size *
sizeof(
float));
1532 PyErr_Format(PyExc_AttributeError,
1533 "Vector addition: (%s + %s) "
1534 "invalid type for this operation",
1535 Py_TYPE(
v1)->tp_name,
1536 Py_TYPE(
v2)->tp_name);
1547 if (vec1->
size != vec2->size) {
1548 PyErr_SetString(PyExc_AttributeError,
1550 "vectors must have the same dimensions for this operation");
1554 vec = PyMem_Malloc(vec1->
size *
sizeof(
float));
1556 PyErr_SetString(PyExc_MemoryError,
1558 "problem allocating pointer space");
1573 PyErr_Format(PyExc_AttributeError,
1574 "Vector addition: (%s += %s) "
1575 "invalid type for this operation",
1576 Py_TYPE(
v1)->tp_name,
1577 Py_TYPE(
v2)->tp_name);
1583 if (vec1->
size != vec2->size) {
1584 PyErr_SetString(PyExc_AttributeError,
1586 "vectors must have the same dimensions for this operation");
1608 PyErr_Format(PyExc_AttributeError,
1609 "Vector subtraction: (%s - %s) "
1610 "invalid type for this operation",
1611 Py_TYPE(
v1)->tp_name,
1612 Py_TYPE(
v2)->tp_name);
1622 if (vec1->
size != vec2->size) {
1623 PyErr_SetString(PyExc_AttributeError,
1624 "Vector subtraction: "
1625 "vectors must have the same dimensions for this operation");
1629 vec = PyMem_Malloc(vec1->
size *
sizeof(
float));
1631 PyErr_SetString(PyExc_MemoryError,
1633 "problem allocating pointer space");
1648 PyErr_Format(PyExc_AttributeError,
1649 "Vector subtraction: (%s -= %s) "
1650 "invalid type for this operation",
1651 Py_TYPE(
v1)->tp_name,
1652 Py_TYPE(
v2)->tp_name);
1658 if (vec1->
size != vec2->size) {
1659 PyErr_SetString(PyExc_AttributeError,
1660 "Vector subtraction: "
1661 "vectors must have the same dimensions for this operation");
1693 int row,
col,
z = 0;
1700 PyErr_SetString(PyExc_ValueError,
1702 "len(matrix.col) and len(vector) must be the same, "
1703 "except for 4x4 matrix * 3D vector.");
1708 memcpy(vec_cpy, vec->vec, vec->
size *
sizeof(
float));
1712 for (row = 0; row < mat->
num_row; row++) {
1725 float *tvec = PyMem_Malloc(vec->
size *
sizeof(
float));
1727 PyErr_SetString(PyExc_MemoryError,
1729 "problem allocating pointer space");
1739 float *tvec = PyMem_Malloc(vec1->
size *
sizeof(
float));
1741 PyErr_SetString(PyExc_MemoryError,
1743 "problem allocating pointer space");
1773 if (vec1->
size != vec2->size) {
1774 PyErr_SetString(PyExc_ValueError,
1775 "Vector multiplication: "
1776 "vectors must have the same dimensions for this operation");
1784 if (((scalar = PyFloat_AsDouble(
v2)) == -1.0f && PyErr_Occurred()) == 0) {
1789 if (((scalar = PyFloat_AsDouble(
v1)) == -1.0f && PyErr_Occurred()) == 0) {
1794 PyErr_Format(PyExc_TypeError,
1795 "Element-wise multiplication: "
1796 "not supported between '%.200s' and '%.200s' types",
1797 Py_TYPE(
v1)->tp_name,
1798 Py_TYPE(
v2)->tp_name);
1828 if (vec1->
size != vec2->size) {
1829 PyErr_SetString(PyExc_ValueError,
1830 "Vector multiplication: "
1831 "vectors must have the same dimensions for this operation");
1838 else if (vec1 && (((scalar = PyFloat_AsDouble(
v2)) == -1.0f && PyErr_Occurred()) ==
1843 PyErr_Format(PyExc_TypeError,
1844 "In place element-wise multiplication: "
1845 "not supported between '%.200s' and '%.200s' types",
1846 Py_TYPE(
v1)->tp_name,
1847 Py_TYPE(
v2)->tp_name);
1878 if (vec1->
size != vec2->size) {
1879 PyErr_SetString(PyExc_ValueError,
1880 "Vector multiplication: "
1881 "vectors must have the same dimensions for this operation");
1886 return PyFloat_FromDouble(
dot_vn_vn(vec1->vec, vec2->vec, vec1->
size));
1911 PyErr_Format(PyExc_TypeError,
1912 "Vector multiplication: "
1913 "not supported between '%.200s' and '%.200s' types",
1914 Py_TYPE(
v1)->tp_name,
1915 Py_TYPE(
v2)->tp_name);
1921 PyErr_Format(PyExc_TypeError,
1922 "In place vector multiplication: "
1923 "not supported between '%.200s' and '%.200s' types",
1924 Py_TYPE(
v1)->tp_name,
1925 Py_TYPE(
v2)->tp_name);
1932 float *vec =
NULL, scalar;
1936 PyErr_SetString(PyExc_TypeError,
1938 "Vector must be divided by a float");
1947 if ((scalar = PyFloat_AsDouble(
v2)) == -1.0f && PyErr_Occurred()) {
1949 PyErr_SetString(PyExc_TypeError,
1951 "Vector must be divided by a float");
1955 if (scalar == 0.0f) {
1956 PyErr_SetString(PyExc_ZeroDivisionError,
1958 "divide by zero error");
1962 vec = PyMem_Malloc(vec1->
size *
sizeof(
float));
1965 PyErr_SetString(PyExc_MemoryError,
1967 "problem allocating pointer space");
1986 if ((scalar = PyFloat_AsDouble(
v2)) == -1.0f && PyErr_Occurred()) {
1988 PyErr_SetString(PyExc_TypeError,
1990 "Vector must be divided by a float");
1994 if (scalar == 0.0f) {
1995 PyErr_SetString(PyExc_ZeroDivisionError,
1997 "divide by zero error");
2019 tvec = PyMem_Malloc(
self->size *
sizeof(
float));
2026 static PyObject *
Vector_richcmpr(PyObject *objectA, PyObject *objectB,
int comparison_type)
2030 const double epsilon = 0.000001f;
2034 if (comparison_type == Py_NE) {
2047 if (vecA->
size != vecB->size) {
2048 if (comparison_type == Py_NE) {
2055 switch (comparison_type) {
2097 printf(
"The result of the comparison could not be evaluated");
2136 if (PyIndex_Check(item)) {
2138 i = PyNumber_AsSsize_t(item, PyExc_IndexError);
2139 if (i == -1 && PyErr_Occurred()) {
2147 if (PySlice_Check(item)) {
2148 Py_ssize_t start, stop, step, slicelength;
2150 if (PySlice_GetIndicesEx(item,
self->size, &start, &stop, &step, &slicelength) < 0) {
2154 if (slicelength <= 0) {
2155 return PyTuple_New(0);
2161 PyErr_SetString(PyExc_IndexError,
"slice steps not supported with vectors");
2166 PyExc_TypeError,
"vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
2172 if (PyIndex_Check(item)) {
2173 Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
2174 if (i == -1 && PyErr_Occurred()) {
2182 if (PySlice_Check(item)) {
2183 Py_ssize_t start, stop, step, slicelength;
2185 if (PySlice_GetIndicesEx(item,
self->size, &start, &stop, &step, &slicelength) < 0) {
2193 PyErr_SetString(PyExc_IndexError,
"slice steps not supported with vectors");
2198 PyExc_TypeError,
"vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
2253 PyDoc_STRVAR(Vector_axis_z_doc,
"Vector Z axis (3D Vectors only).\n\n:type: float");
2254 PyDoc_STRVAR(Vector_axis_w_doc,
"Vector W axis (4D Vectors only).\n\n:type: float");
2280 double dot = 0.0f, param;
2286 if ((param = PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) {
2287 PyErr_SetString(PyExc_TypeError,
"length must be set to a number");
2292 PyErr_SetString(PyExc_ValueError,
"cannot set a vectors length to a negative value");
2323 PyDoc_STRVAR(Vector_length_squared_doc,
"Vector length squared (v.dot(v)).\n\n:type: float");
2399 uint swizzleClosure;
2410 if (axis_from >=
self->size) {
2411 PyErr_SetString(PyExc_AttributeError,
2413 "specified axis not present");
2417 vec[axis_to] =
self->vec[axis_from];
2444 uint swizzleClosure;
2460 if (axis_to >=
self->size) {
2461 PyErr_SetString(PyExc_AttributeError,
2463 "specified axis not present");
2470 if (((scalarVal = PyFloat_AsDouble(value)) == -1 && PyErr_Occurred()) == 0) {
2474 vec_assign[i] = scalarVal;
2477 size_from = axis_from;
2479 else if (((
void)PyErr_Clear()),
2481 vec_assign, 2, 4, value,
"mathutils.Vector.**** = swizzle assignment")) == -1) {
2485 if (axis_from != size_from) {
2486 PyErr_SetString(PyExc_AttributeError,
"Vector swizzle: size does not match swizzle");
2497 memcpy(tvec,
self->vec,
self->size *
sizeof(
float));
2501 tvec[axis_to] = vec_assign[axis_from];
2508 memcpy(
self->vec, tvec,
self->size *
sizeof(
float));
2518 #define _SWIZZLE1(a) ((a) | SWIZZLE_VALID_AXIS)
2519 #define _SWIZZLE2(a, b) (_SWIZZLE1(a) | (((b) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS)))
2520 #define _SWIZZLE3(a, b, c) \
2521 (_SWIZZLE2(a, b) | (((c) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)))
2522 #define _SWIZZLE4(a, b, c, d) \
2523 (_SWIZZLE3(a, b, c) | (((d) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3)))
2525 #define SWIZZLE2(a, b) POINTER_FROM_INT(_SWIZZLE2(a, b))
2526 #define SWIZZLE3(a, b, c) POINTER_FROM_INT(_SWIZZLE3(a, b, c))
2527 #define SWIZZLE4(a, b, c, d) POINTER_FROM_INT(_SWIZZLE4(a, b, c, d))
2541 Vector_length_squared_doc,
2894 #undef AXIS_FROM_CHAR
2921 int row,
col,
z = 0, vec_size = vec->
size;
2923 if (mat->
num_row != vec_size) {
2924 if (mat->
num_row == 4 && vec_size == 3) {
2928 PyErr_SetString(PyExc_ValueError,
2929 "vector * matrix: matrix column size "
2930 "and the vector size must be the same");
2939 memcpy(vec_cpy, vec->vec, vec_size *
sizeof(
float));
2945 for (row = 0; row < mat->
num_row; row++) {
2955 ".. method:: negate()\n"
2957 " Set all values to their negative.\n");
2972 {
"Fill", (PyCFunction)
C_Vector_Fill, METH_VARARGS | METH_CLASS, C_Vector_Fill_doc},
2973 {
"Range", (PyCFunction)
C_Vector_Range, METH_VARARGS | METH_CLASS, C_Vector_Range_doc},
2974 {
"Linspace", (PyCFunction)
C_Vector_Linspace, METH_VARARGS | METH_CLASS, C_Vector_Linspace_doc},
2975 {
"Repeat", (PyCFunction)
C_Vector_Repeat, METH_VARARGS | METH_CLASS, C_Vector_Repeat_doc},
2978 {
"zero", (PyCFunction)
Vector_zero, METH_NOARGS, Vector_zero_doc},
2979 {
"negate", (PyCFunction)
Vector_negate, METH_NOARGS, Vector_negate_doc},
2982 {
"normalize", (PyCFunction)
Vector_normalize, METH_NOARGS, Vector_normalize_doc},
2983 {
"normalized", (PyCFunction)
Vector_normalized, METH_NOARGS, Vector_normalized_doc},
2985 {
"resize", (PyCFunction)
Vector_resize, METH_O, Vector_resize_doc},
2986 {
"resized", (PyCFunction)
Vector_resized, METH_O, Vector_resized_doc},
2987 {
"to_2d", (PyCFunction)
Vector_to_2d, METH_NOARGS, Vector_to_2d_doc},
2988 {
"resize_2d", (PyCFunction)
Vector_resize_2d, METH_NOARGS, Vector_resize_2d_doc},
2989 {
"to_3d", (PyCFunction)
Vector_to_3d, METH_NOARGS, Vector_to_3d_doc},
2990 {
"resize_3d", (PyCFunction)
Vector_resize_3d, METH_NOARGS, Vector_resize_3d_doc},
2991 {
"to_4d", (PyCFunction)
Vector_to_4d, METH_NOARGS, Vector_to_4d_doc},
2992 {
"resize_4d", (PyCFunction)
Vector_resize_4d, METH_NOARGS, Vector_resize_4d_doc},
2993 {
"to_tuple", (PyCFunction)
Vector_to_tuple, METH_VARARGS, Vector_to_tuple_doc},
2995 {
"orthogonal", (PyCFunction)
Vector_orthogonal, METH_NOARGS, Vector_orthogonal_doc},
2998 {
"reflect", (PyCFunction)
Vector_reflect, METH_O, Vector_reflect_doc},
2999 {
"cross", (PyCFunction)
Vector_cross, METH_O, Vector_cross_doc},
3000 {
"dot", (PyCFunction)
Vector_dot, METH_O, Vector_dot_doc},
3001 {
"angle", (PyCFunction)
Vector_angle, METH_VARARGS, Vector_angle_doc},
3002 {
"angle_signed", (PyCFunction)
Vector_angle_signed, METH_VARARGS, Vector_angle_signed_doc},
3003 {
"rotation_difference",
3006 Vector_rotation_difference_doc},
3007 {
"project", (PyCFunction)
Vector_project, METH_O, Vector_project_doc},
3008 {
"lerp", (PyCFunction)
Vector_lerp, METH_VARARGS, Vector_lerp_doc},
3009 {
"slerp", (PyCFunction)
Vector_slerp, METH_VARARGS, Vector_slerp_doc},
3010 {
"rotate", (PyCFunction)
Vector_rotate, METH_O, Vector_rotate_doc},
3015 {
"copy", (PyCFunction)
Vector_copy, METH_NOARGS, Vector_copy_doc},
3029 ".. class:: Vector(seq)\n"
3031 " This object gives access to Vectors in Blender.\n"
3033 " :param seq: Components of the vector, must be a sequence of at least two\n"
3034 " :type seq: sequence of numbers\n");
3036 PyVarObject_HEAD_INIT(
NULL, 0)
3061 #ifndef MATH_STANDALONE
3073 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
3126 PyErr_SetString(PyExc_RuntimeError,
"Vector(): invalid size");
3130 vec_alloc = PyMem_Malloc(
size *
sizeof(
float));
3132 PyErr_SetString(PyExc_MemoryError,
3134 "problem allocating data");
3140 self->vec = vec_alloc;
3144 self->cb_user =
NULL;
3145 self->cb_type =
self->cb_subtype = 0;
3148 memcpy(
self->vec, vec,
size *
sizeof(
float));
3153 self->vec[3] = 1.0f;
3159 PyMem_Free(vec_alloc);
3162 return (PyObject *)
self;
3175 PyErr_SetString(PyExc_RuntimeError,
"Vector(): invalid size");
3184 self->cb_user =
NULL;
3185 self->cb_type =
self->cb_subtype = 0;
3190 return (PyObject *)
self;
3202 self->cb_user = cb_user;
3203 self->cb_type = cb_type;
3204 self->cb_subtype = cb_subtype;
3205 PyObject_GC_Track(
self);
3208 return (PyObject *)
self;
3222 return (PyObject *)
self;
typedef float(TangentPoint)[2]
A dynamically sized string ADT.
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
MINLINE float saacos(float fac)
double double_round(double x, int ndigits)
void mul_m3_v3(const float M[3][3], float r[3])
void normalize_m2_m2(float R[2][2], const float M[2][2]) ATTR_NONNULL()
void mul_m2_v2(const float M[2][2], float v[2])
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
void interp_dot_slerp(const float t, const float cosom, float w[2])
void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
void copy_vn_fl(float *array_tar, const int size, const float val)
void negate_vn(float *array_tar, const int size)
void sub_vn_vn(float *array_tar, const float *array_src, const int size)
void mul_vn_vn_fl(float *array_tar, const float *array_src, const int size, const float f)
void reflect_v3_v3v3(float out[3], const float vec[3], const float normal[3])
float normalize_vn(float *array_tar, const int size)
MINLINE float normalize_v3(float r[3])
void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size)
void add_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size)
void add_vn_vn(float *array_tar, const float *array_src, const int size)
MINLINE void negate_v3_v3(float r[3], const float a[3])
float normalize_vn_vn(float *array_tar, const float *array_src, const int size)
void negate_vn_vn(float *array_tar, const float *array_src, const int size)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
void ortho_v3_v3(float out[3], const float v[3])
float angle_signed_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3_v3(float r[3], const float a[3])
void ortho_v2_v2(float out[2], const float v[2])
void mul_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size)
void range_vn_fl(float *array_tar, const int size, const float start, const float step)
void interp_vn_vn(float *array_tar, const float *array_src, const float t, const int size)
void mul_vn_vn(float *array_tar, const float *array_src, const int size)
MINLINE bool is_zero_v2(const float a[3]) ATTR_WARN_UNUSED_RESULT
double len_squared_vn(const float *array, const int size) ATTR_WARN_UNUSED_RESULT
void mul_vn_fl(float *array_tar, const int size, const float f)
double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size) ATTR_WARN_UNUSED_RESULT
#define POINTER_AS_INT(i)
typedef double(DMatrix)[4][4]
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Group RGB to Bright Vector Camera CLAMP
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
PyObject * BaseMathObject_freeze(BaseMathObject *self)
PyObject * BaseMathObject_is_frozen_get(BaseMathObject *self, void *UNUSED(closure))
PyObject * BaseMathObject_is_wrapped_get(BaseMathObject *self, void *UNUSED(closure))
PyObject * mathutils_dynstr_to_py(struct DynStr *ds)
Py_hash_t mathutils_array_hash(const float *array, size_t array_len)
void BaseMathObject_dealloc(BaseMathObject *self)
int EXPP_VectorsAreEqual(const float *vecA, const float *vecB, int size, int floatSteps)
PyObject * BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure))
char BaseMathObject_is_wrapped_doc[]
char BaseMathObject_is_frozen_doc[]
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix)
char BaseMathObject_owner_doc[]
char BaseMathObject_freeze_doc[]
int BaseMathObject_clear(BaseMathObject *self)
int BaseMathObject_traverse(BaseMathObject *self, visitproc visit, void *arg)
int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, const char *error_prefix)
#define BaseMath_ReadCallback_ForWrite(_self)
#define BaseMath_ReadIndexCallback(_self, _index)
#define BaseMath_WriteCallback(_self)
#define BASE_MATH_NEW(struct_name, root_type, base_type)
#define BaseMathObject_Prepare_ForHash(_self)
#define BASE_MATH_FLAG_DEFAULT
#define BaseMath_Prepare_ForWrite(_self)
#define BaseMath_ReadCallback(_self)
#define BaseMath_WriteIndexCallback(_self, _index)
int Matrix_Parse2x2(PyObject *o, void *p)
#define MatrixObject_Check(v)
#define MATRIX_ITEM(_mat, _row, _col)
PyObject * Quaternion_CreatePyObject(const float quat[4], PyTypeObject *base_type)
static PyObject * Vector_subscript(VectorObject *self, PyObject *item)
static PyObject * Vector_slice(VectorObject *self, int begin, int end)
static PySequenceMethods Vector_SeqMethods
static PyObject * Vector_zero(VectorObject *self)
static PyObject * Vector_swizzle_get(VectorObject *self, void *closure)
static PyObject * C_Vector_Fill(PyObject *cls, PyObject *args)
static PyObject * Vector_angle(VectorObject *self, PyObject *args)
PyDoc_STRVAR(C_Vector_Fill_doc, ".. classmethod:: Fill(size, fill=0.0)\n" "\n" " Create a vector of length size with all values set to fill.\n" "\n" " :arg size: The length of the vector to be created.\n" " :type size: int\n" " :arg fill: The value used to fill the vector.\n" " :type fill: float\n")
PyObject * Vector_CreatePyObject_alloc(float *vec, const int size, PyTypeObject *base_type)
static struct PyMethodDef Vector_methods[]
#define SWIZZLE4(a, b, c, d)
static PyObject * Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure)
static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value, const bool is_attr)
static PyObject * vec__apply_to_copy(PyObject *(*vec_func)(VectorObject *), VectorObject *self)
static int Vector_len(VectorObject *self)
static PyObject * C_Vector_Linspace(PyObject *cls, PyObject *args)
static PyObject * Vector_orthogonal(VectorObject *self)
#define SWIZZLE_VALID_AXIS
static PyObject * Vector_dot(VectorObject *self, PyObject *value)
static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *value)
static PyObject * vector_mul_float(VectorObject *vec, const float scalar)
static Py_hash_t Vector_hash(VectorObject *self)
static PyObject * Vector_imatmul(PyObject *v1, PyObject *v2)
static PyObject * Vector_rotation_difference(VectorObject *self, PyObject *value)
static PyObject * Vector_to_track_quat(VectorObject *self, PyObject *args)
static PyObject * Vector_negate(VectorObject *self)
static PyObject * Vector_repr(VectorObject *self)
static PyObject * Vector_div(PyObject *v1, PyObject *v2)
PyObject * Vector_CreatePyObject(const float *vec, const int size, PyTypeObject *base_type)
static PyObject * Vector_slerp(VectorObject *self, PyObject *args)
static PyObject * Vector_mul(PyObject *v1, PyObject *v2)
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int size, uchar cb_type, uchar cb_subtype)
static PyObject * Vector_isub(PyObject *v1, PyObject *v2)
static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *seq)
static PyObject * Vector_cross(VectorObject *self, PyObject *value)
static PyNumberMethods Vector_NumMethods
static PyObject * C_Vector_Range(PyObject *cls, PyObject *args)
static PyObject * Vector_idiv(PyObject *v1, PyObject *v2)
static int row_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat)
static PyObject * Vector_normalize(VectorObject *self)
static PyObject * Vector_axis_get(VectorObject *self, void *type)
static PyObject * Vector_resized(VectorObject *self, PyObject *value)
static PyObject * Vector_copy(VectorObject *self)
static PyObject * Vector_resize_4d(VectorObject *self)
static PyObject * Vector_lerp(VectorObject *self, PyObject *args)
static PyObject * Vector_iadd(PyObject *v1, PyObject *v2)
static PyObject * Vector_resize_2d(VectorObject *self)
static PyObject * Vector_neg(VectorObject *self)
static PyObject * Vector_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type)
static PyObject * Vector_str(VectorObject *self)
static PyObject * vector_item_internal(VectorObject *self, int i, const bool is_attr)
static PyObject * Vector_rotate(VectorObject *self, PyObject *value)
static int Vector_length_set(VectorObject *self, PyObject *value)
static PyObject * Vector_deepcopy(VectorObject *self, PyObject *args)
static PyObject * Vector_to_2d(VectorObject *self)
static PyObject * Vector_to_3d(VectorObject *self)
static PyObject * Vector_angle_signed(VectorObject *self, PyObject *args)
static PyObject * Vector_length_squared_get(VectorObject *self, void *UNUSED(closure))
static PyObject * Vector_reflect(VectorObject *self, PyObject *value)
static PyObject * Vector_project(VectorObject *self, PyObject *value)
static PyObject * Vector_to_tuple(VectorObject *self, PyObject *args)
static PyObject * Vector_normalized(VectorObject *self)
static PyObject * Vector_to_4d(VectorObject *self)
static PyObject * Vector_length_get(VectorObject *self, void *UNUSED(closure))
static PyObject * Vector_matmul(PyObject *v1, PyObject *v2)
#define SWIZZLE_BITS_PER_AXIS
static PyObject * C_Vector_Repeat(PyObject *cls, PyObject *args)
static PyObject * Vector_imul(PyObject *v1, PyObject *v2)
static PyObject * Vector_add(PyObject *v1, PyObject *v2)
PyObject * Vector_CreatePyObject_wrap(float *vec, const int size, PyTypeObject *base_type)
static PyGetSetDef Vector_getseters[]
static PyObject * Vector_sub(PyObject *v1, PyObject *v2)
static int Vector_axis_set(VectorObject *self, PyObject *value, void *type)
static PyObject * Vector_to_tuple_ex(VectorObject *self, int ndigits)
static PyMappingMethods Vector_AsMapping
#define SWIZZLE3(a, b, c)
static PyObject * Vector_resize(VectorObject *self, PyObject *value)
static int Vector_ass_item(VectorObject *self, int i, PyObject *value)
int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat)
static PyObject * Vector_resize_3d(VectorObject *self)
static PyObject * vector_mul_vec(VectorObject *vec1, VectorObject *vec2)
static PyObject * Vector_item(VectorObject *self, int i)
#define VectorObject_Check(v)
int PyC_CheckArgs_DeepCopy(PyObject *args)
ccl_device_inline float3 reflect(const float3 incident, const float3 normal)