14 #include "../generic/py_capi_utils.h"
16 #ifndef MATH_STANDALONE
25 #define MAX_DIMENSIONS 4
32 #define SWIZZLE_BITS_PER_AXIS 3
33 #define SWIZZLE_VALID_AXIS 0x4
34 #define SWIZZLE_AXIS 0x3
60 if (mat->
row_num == 4 && vec_num == 3) {
64 PyErr_SetString(PyExc_ValueError,
65 "vector * matrix: matrix column size "
66 "and the vector size must be the same");
75 memcpy(vec_cpy, vec->vec, vec_num *
sizeof(
float));
81 for (row = 0; row < mat->
row_num; row++) {
95 return (PyObject *)
ret;
108 ret = PyTuple_New(
self->vec_num);
111 for (i = 0; i <
self->vec_num; i++) {
116 for (i = 0; i <
self->vec_num; i++) {
117 PyTuple_SET_ITEM(
ret, i, PyFloat_FromDouble(
self->vec[i]));
139 if (kwds && PyDict_Size(kwds)) {
140 PyErr_SetString(PyExc_TypeError,
142 "takes no keyword args");
146 switch (PyTuple_GET_SIZE(args)) {
148 vec = PyMem_Malloc(vec_num *
sizeof(
float));
151 PyErr_SetString(PyExc_MemoryError,
153 "problem allocating pointer space");
161 &vec, 2, PyTuple_GET_ITEM(args, 0),
"mathutils.Vector()")) == -1) {
166 PyErr_SetString(PyExc_TypeError,
167 "mathutils.Vector(): "
168 "more than a single arg given");
181 ".. classmethod:: Fill(size, fill=0.0)\n"
183 " Create a vector of length size with all values set to fill.\n"
185 " :arg size: The length of the vector to be created.\n"
187 " :arg fill: The value used to fill the vector.\n"
188 " :type fill: float\n");
195 if (!PyArg_ParseTuple(args,
"i|f:Vector.Fill", &vec_num, &fill)) {
200 PyErr_SetString(PyExc_RuntimeError,
"Vector(): invalid size");
204 vec = PyMem_Malloc(vec_num *
sizeof(
float));
207 PyErr_SetString(PyExc_MemoryError,
209 "problem allocating pointer space");
219 ".. classmethod:: Range(start, stop, step=1)\n"
221 " Create a filled with a range of values.\n"
223 " :arg start: The start of the range used to fill the vector.\n"
224 " :type start: int\n"
225 " :arg stop: The end of the range used to fill the vector.\n"
227 " :arg step: The step between successive values in the vector.\n"
228 " :type step: int\n");
236 if (!PyArg_ParseTuple(args,
"i|ii:Vector.Range", &start, &stop, &step)) {
240 switch (PyTuple_GET_SIZE(args)) {
247 PyErr_SetString(PyExc_RuntimeError,
248 "Start value is larger "
249 "than the stop value");
253 vec_num = stop - start;
257 PyErr_SetString(PyExc_RuntimeError,
258 "Start value is larger "
259 "than the stop value");
263 vec_num = (stop - start);
265 if ((vec_num % step) != 0) {
275 PyErr_SetString(PyExc_RuntimeError,
"Vector(): invalid size");
279 vec = PyMem_Malloc(vec_num *
sizeof(
float));
282 PyErr_SetString(PyExc_MemoryError,
284 "problem allocating pointer space");
288 range_vn_fl(vec, vec_num, (
float)start, (
float)step);
294 ".. classmethod:: Linspace(start, stop, size)\n"
296 " Create a vector of the specified size which is filled with linearly spaced "
297 "values between start and stop values.\n"
299 " :arg start: The start of the range used to fill the vector.\n"
300 " :type start: int\n"
301 " :arg stop: The end of the range used to fill the vector.\n"
303 " :arg size: The size of the vector to be created.\n"
304 " :type size: int\n");
309 float start, end, step;
311 if (!PyArg_ParseTuple(args,
"ffi:Vector.Linspace", &start, &end, &vec_num)) {
316 PyErr_SetString(PyExc_RuntimeError,
"Vector.Linspace(): invalid size");
320 step = (end - start) / (
float)(vec_num - 1);
322 vec = PyMem_Malloc(vec_num *
sizeof(
float));
325 PyErr_SetString(PyExc_MemoryError,
326 "Vector.Linspace(): "
327 "problem allocating pointer space");
338 ".. classmethod:: Repeat(vector, size)\n"
340 " Create a vector by repeating the values in vector until the required size is reached.\n"
342 " :arg tuple: The vector to draw values from.\n"
343 " :type tuple: :class:`mathutils.Vector`\n"
344 " :arg size: The size of the vector to be created.\n"
345 " :type size: int\n");
349 float *iter_vec =
NULL;
350 int i, vec_num, value_num;
353 if (!PyArg_ParseTuple(args,
"Oi:Vector.Repeat", &value, &vec_num)) {
358 PyErr_SetString(PyExc_RuntimeError,
"Vector.Repeat(): invalid vec_num");
363 &iter_vec, 2, value,
"Vector.Repeat(vector, vec_num), invalid 'vector' arg")) == -1) {
367 if (iter_vec ==
NULL) {
368 PyErr_SetString(PyExc_MemoryError,
370 "problem allocating pointer space");
374 vec = PyMem_Malloc(vec_num *
sizeof(
float));
377 PyMem_Free(iter_vec);
378 PyErr_SetString(PyExc_MemoryError,
380 "problem allocating pointer space");
385 while (i < vec_num) {
386 vec[i] = iter_vec[i % value_num];
390 PyMem_Free(iter_vec);
402 ".. method:: zero()\n"
404 " Set all values to zero.\n");
427 ".. method:: normalize()\n"
429 " Normalize the vector, making the length of the vector always 1.0.\n"
431 " .. warning:: Normalizing a vector where all values are zero has no effect.\n"
433 " .. note:: Normalize works for vectors of all sizes,\n"
434 " however 4D Vectors w axis is left untouched.\n");
437 const int vec_num = (
self->vec_num == 4 ? 3 :
self->vec_num);
448 ".. method:: normalized()\n"
450 " Return a new, normalized vector.\n"
452 " :return: a normalized copy of the vector\n"
453 " :rtype: :class:`Vector`\n");
466 ".. method:: resize(size=3)\n"
468 " Resize the vector to have size number of elements.\n");
474 PyErr_SetString(PyExc_TypeError,
476 "cannot resize wrapped data - only python vectors");
480 PyErr_SetString(PyExc_TypeError,
482 "cannot resize a vector that has an owner");
486 if ((vec_num = PyC_Long_AsI32(value)) == -1) {
487 PyErr_SetString(PyExc_TypeError,
488 "Vector.resize(size): "
489 "expected size argument to be an integer");
494 PyErr_SetString(PyExc_RuntimeError,
"Vector.resize(): invalid size");
498 self->vec = PyMem_Realloc(
self->vec, (vec_num *
sizeof(
float)));
500 PyErr_SetString(PyExc_MemoryError,
502 "problem allocating pointer space");
507 if (vec_num >
self->vec_num) {
511 self->vec_num = vec_num;
516 ".. method:: resized(size=3)\n"
518 " Return a resized copy of the vector with size number of elements.\n"
520 " :return: a new vector\n"
521 " :rtype: :class:`Vector`\n");
527 if ((vec_num = PyLong_AsLong(value)) == -1) {
532 PyErr_SetString(PyExc_RuntimeError,
"Vector.resized(): invalid size");
536 vec = PyMem_Malloc(vec_num *
sizeof(
float));
539 PyErr_SetString(PyExc_MemoryError,
541 "problem allocating pointer space");
546 memcpy(vec,
self->vec,
self->vec_num *
sizeof(
float));
552 ".. method:: resize_2d()\n"
554 " Resize the vector to 2D (x, y).\n");
558 PyErr_SetString(PyExc_TypeError,
559 "Vector.resize_2d(): "
560 "cannot resize wrapped data - only python vectors");
564 PyErr_SetString(PyExc_TypeError,
565 "Vector.resize_2d(): "
566 "cannot resize a vector that has an owner");
570 self->vec = PyMem_Realloc(
self->vec,
sizeof(
float[2]));
572 PyErr_SetString(PyExc_MemoryError,
573 "Vector.resize_2d(): "
574 "problem allocating pointer space");
583 ".. method:: resize_3d()\n"
585 " Resize the vector to 3D (x, y, z).\n");
589 PyErr_SetString(PyExc_TypeError,
590 "Vector.resize_3d(): "
591 "cannot resize wrapped data - only python vectors");
595 PyErr_SetString(PyExc_TypeError,
596 "Vector.resize_3d(): "
597 "cannot resize a vector that has an owner");
601 self->vec = PyMem_Realloc(
self->vec,
sizeof(
float[3]));
603 PyErr_SetString(PyExc_MemoryError,
604 "Vector.resize_3d(): "
605 "problem allocating pointer space");
609 if (
self->vec_num == 2) {
618 ".. method:: resize_4d()\n"
620 " Resize the vector to 4D (x, y, z, w).\n");
624 PyErr_SetString(PyExc_TypeError,
625 "Vector.resize_4d(): "
626 "cannot resize wrapped data - only python vectors");
630 PyErr_SetString(PyExc_TypeError,
631 "Vector.resize_4d(): "
632 "cannot resize a vector that has an owner");
636 self->vec = PyMem_Realloc(
self->vec,
sizeof(
float[4]));
638 PyErr_SetString(PyExc_MemoryError,
639 "Vector.resize_4d(): "
640 "problem allocating pointer space");
644 if (
self->vec_num == 2) {
648 else if (
self->vec_num == 3) {
662 ".. method:: to_2d()\n"
664 " Return a 2d copy of the vector.\n"
666 " :return: a new vector\n"
667 " :rtype: :class:`Vector`\n");
677 ".. method:: to_3d()\n"
679 " Return a 3d copy of the vector.\n"
681 " :return: a new vector\n"
682 " :rtype: :class:`Vector`\n");
685 float tvec[3] = {0.0f};
691 memcpy(tvec,
self->vec,
sizeof(
float) *
MIN2(
self->vec_num, 3));
695 ".. method:: to_4d()\n"
697 " Return a 4d copy of the vector.\n"
699 " :return: a new vector\n"
700 " :rtype: :class:`Vector`\n");
703 float tvec[4] = {0.0f, 0.0f, 0.0f, 1.0f};
709 memcpy(tvec,
self->vec,
sizeof(
float) *
MIN2(
self->vec_num, 4));
720 ".. method:: to_tuple(precision=-1)\n"
722 " Return this vector as a tuple with.\n"
724 " :arg precision: The number to round the value to in [-1, 21].\n"
725 " :type precision: int\n"
726 " :return: the values of the vector rounded by *precision*\n"
732 if (!PyArg_ParseTuple(args,
"|i:to_tuple", &ndigits)) {
736 if (ndigits > 22 || ndigits < 0) {
737 PyErr_SetString(PyExc_ValueError,
738 "Vector.to_tuple(ndigits): "
739 "ndigits must be between 0 and 21");
743 if (PyTuple_GET_SIZE(args) == 0) {
761 ".. method:: to_track_quat(track, up)\n"
763 " Return a quaternion rotation from the vector and the track and up axis.\n"
765 " :arg track: Track axis in ['X', 'Y', 'Z', '-X', '-Y', '-Z'].\n"
766 " :type track: string\n"
767 " :arg up: Up axis in ['X', 'Y', 'Z'].\n"
768 " :type up: string\n"
769 " :return: rotation from the vector and the track and up axis.\n"
770 " :rtype: :class:`Quaternion`\n");
773 float vec[3], quat[4];
774 const char *strack =
NULL;
775 const char *sup =
NULL;
776 short track = 2, up = 1;
778 if (!PyArg_ParseTuple(args,
"|ss:to_track_quat", &strack, &sup)) {
782 if (
self->vec_num != 3) {
783 PyErr_SetString(PyExc_TypeError,
784 "Vector.to_track_quat(): "
785 "only for 3D vectors");
794 const char *axis_err_msg =
"only X, -X, Y, -Y, Z or -Z for track axis";
796 if (strlen(strack) == 2) {
797 if (strack[0] ==
'-') {
809 PyErr_SetString(PyExc_ValueError, axis_err_msg);
814 PyErr_SetString(PyExc_ValueError, axis_err_msg);
818 else if (strlen(strack) == 1) {
831 PyErr_SetString(PyExc_ValueError, axis_err_msg);
836 PyErr_SetString(PyExc_ValueError, axis_err_msg);
842 const char *axis_err_msg =
"only X, Y or Z for up axis";
843 if (strlen(sup) == 1) {
855 PyErr_SetString(PyExc_ValueError, axis_err_msg);
860 PyErr_SetString(PyExc_ValueError, axis_err_msg);
866 PyErr_SetString(PyExc_ValueError,
"Can't have the same axis for track and up");
886 Vector_orthogonal_doc,
887 ".. method:: orthogonal()\n"
889 " Return a perpendicular vector.\n"
891 " :return: a new vector 90 degrees from this vector.\n"
892 " :rtype: :class:`Vector`\n"
894 " .. note:: the axis is undefined, only use when any orthogonal vector is acceptable.\n");
899 if (
self->vec_num > 3) {
900 PyErr_SetString(PyExc_TypeError,
901 "Vector.orthogonal(): "
902 "Vector must be 3D or 2D");
910 if (
self->vec_num == 3) {
930 ".. method:: reflect(mirror)\n"
932 " Return the reflection vector from the *mirror* argument.\n"
934 " :arg mirror: This vector could be a normal from the reflecting surface.\n"
935 " :type mirror: :class:`Vector`\n"
936 " :return: The reflected vector matching the size of this vector.\n"
937 " :rtype: :class:`Vector`\n");
941 float mirror[3], vec[3];
950 tvec, 2, 4, value,
"Vector.reflect(other), invalid 'other' arg")) == -1) {
954 if (
self->vec_num < 2 ||
self->vec_num > 4) {
955 PyErr_SetString(PyExc_ValueError,
"Vector must be 2D, 3D or 4D");
961 mirror[2] = (value_num > 2) ? tvec[2] : 0.0f;
963 vec[0] =
self->vec[0];
964 vec[1] =
self->vec[1];
965 vec[2] = (value_num > 2) ?
self->vec[2] : 0.0f;
980 ".. method:: cross(other)\n"
982 " Return the cross product of this vector and another.\n"
984 " :arg other: The other vector to perform the cross product with.\n"
985 " :type other: :class:`Vector`\n"
986 " :return: The cross product.\n"
987 " :rtype: :class:`Vector` or float when 2D vectors are used\n"
989 " .. note:: both vectors must be 2D or 3D\n");
999 if (
self->vec_num > 3) {
1000 PyErr_SetString(PyExc_ValueError,
"Vector must be 2D or 3D");
1005 tvec,
self->vec_num,
self->vec_num, value,
"Vector.cross(other), invalid 'other' arg") ==
1010 if (
self->vec_num == 3) {
1028 ".. method:: dot(other)\n"
1030 " Return the dot product of this vector and another.\n"
1032 " :arg other: The other vector to perform the dot product with.\n"
1033 " :type other: :class:`Vector`\n"
1034 " :return: The dot product.\n"
1035 " :rtype: float\n");
1046 &tvec,
self->vec_num, value,
"Vector.dot(other), invalid 'other' arg") == -1) {
1063 ".. function:: angle(other, fallback=None)\n"
1065 " Return the angle between two vectors.\n"
1067 " :arg other: another vector to compare the angle with\n"
1068 " :type other: :class:`Vector`\n"
1069 " :arg fallback: return this when the angle can't be calculated (zero length vector),\n"
1070 " (instead of raising a :exc:`ValueError`).\n"
1071 " :type fallback: any\n"
1072 " :return: angle in radians or fallback when given\n"
1073 " :rtype: float\n");
1076 const int vec_num =
MIN2(
self->vec_num, 3);
1079 double dot = 0.0f, dot_self = 0.0f, dot_other = 0.0f;
1081 PyObject *fallback =
NULL;
1083 if (!PyArg_ParseTuple(args,
"O|O:angle", &value, &fallback)) {
1094 tvec,
self->vec_num,
self->vec_num, value,
"Vector.angle(other), invalid 'other' arg") ==
1099 if (
self->vec_num > 4) {
1100 PyErr_SetString(PyExc_ValueError,
"Vector must be 2D, 3D or 4D");
1104 for (
x = 0;
x < vec_num;
x++) {
1105 dot_self += (
double)
self->vec[
x] * (
double)
self->vec[
x];
1106 dot_other += (
double)tvec[
x] * (
double)tvec[
x];
1110 if (!dot_self || !dot_other) {
1113 Py_INCREF(fallback);
1117 PyErr_SetString(PyExc_ValueError,
1118 "Vector.angle(other): "
1119 "zero length vectors have no valid angle");
1133 Vector_angle_signed_doc,
1134 ".. function:: angle_signed(other, fallback)\n"
1136 " Return the signed angle between two 2D vectors (clockwise is positive).\n"
1138 " :arg other: another vector to compare the angle with\n"
1139 " :type other: :class:`Vector`\n"
1140 " :arg fallback: return this when the angle can't be calculated (zero length vector),\n"
1141 " (instead of raising a :exc:`ValueError`).\n"
1142 " :type fallback: any\n"
1143 " :return: angle in radians or fallback when given\n"
1144 " :rtype: float\n");
1150 PyObject *fallback =
NULL;
1152 if (!PyArg_ParseTuple(args,
"O|O:angle_signed", &value, &fallback)) {
1161 tvec, 2, 2, value,
"Vector.angle_signed(other), invalid 'other' arg") == -1) {
1165 if (
self->vec_num != 2) {
1166 PyErr_SetString(PyExc_ValueError,
"Vector must be 2D");
1173 Py_INCREF(fallback);
1177 PyErr_SetString(PyExc_ValueError,
1178 "Vector.angle_signed(other): "
1179 "zero length vectors have no valid angle");
1193 ".. function:: rotation_difference(other)\n"
1195 " Returns a quaternion representing the rotational difference between this\n"
1196 " vector and another.\n"
1198 " :arg other: second vector.\n"
1199 " :type other: :class:`Vector`\n"
1200 " :return: the rotational difference between the two vectors.\n"
1201 " :rtype: :class:`Quaternion`\n"
1203 " .. note:: 2D vectors raise an :exc:`AttributeError`.\n");
1206 float quat[4], vec_a[3], vec_b[3];
1208 if (
self->vec_num < 3 ||
self->vec_num > 4) {
1209 PyErr_SetString(PyExc_ValueError,
1210 "vec.difference(value): "
1211 "expects both vectors to be size 3 or 4");
1220 vec_b, 3,
MAX_DIMENSIONS, value,
"Vector.difference(other), invalid 'other' arg") ==
1240 ".. function:: project(other)\n"
1242 " Return the projection of this vector onto the *other*.\n"
1244 " :arg other: second vector.\n"
1245 " :type other: :class:`Vector`\n"
1246 " :return: the parallel projection vector\n"
1247 " :rtype: :class:`Vector`\n");
1250 const int vec_num =
self->vec_num;
1252 double dot = 0.0f, dot2 = 0.0f;
1260 &tvec, vec_num, value,
"Vector.project(other), invalid 'other' arg") == -1) {
1265 for (
x = 0;
x < vec_num;
x++) {
1267 dot2 += (
double)(tvec[
x] * tvec[
x]);
1271 for (
x = 0;
x < vec_num;
x++) {
1284 ".. function:: lerp(other, factor)\n"
1286 " Returns the interpolation of two vectors.\n"
1288 " :arg other: value to interpolate with.\n"
1289 " :type other: :class:`Vector`\n"
1290 " :arg factor: The interpolation value in [0.0, 1.0].\n"
1291 " :type factor: float\n"
1292 " :return: The interpolated vector.\n"
1293 " :rtype: :class:`Vector`\n");
1296 const int vec_num =
self->vec_num;
1297 PyObject *value =
NULL;
1301 if (!PyArg_ParseTuple(args,
"Of:lerp", &value, &fac)) {
1310 &tvec, vec_num, value,
"Vector.lerp(other), invalid 'other' arg") == -1) {
1326 ".. function:: slerp(other, factor, fallback=None)\n"
1328 " Returns the interpolation of two non-zero vectors (spherical coordinates).\n"
1330 " :arg other: value to interpolate with.\n"
1331 " :type other: :class:`Vector`\n"
1332 " :arg factor: The interpolation value typically in [0.0, 1.0].\n"
1333 " :type factor: float\n"
1334 " :arg fallback: return this when the vector can't be calculated (zero length "
1335 "vector or direct opposites),\n"
1336 " (instead of raising a :exc:`ValueError`).\n"
1337 " :type fallback: any\n"
1338 " :return: The interpolated vector.\n"
1339 " :rtype: :class:`Vector`\n");
1342 const int vec_num =
self->vec_num;
1343 PyObject *value =
NULL;
1344 float fac, cosom,
w[2];
1345 float self_vec[3], other_vec[3], ret_vec[3];
1346 float self_len_sq, other_len_sq;
1348 PyObject *fallback =
NULL;
1350 if (!PyArg_ParseTuple(args,
"Of|O:slerp", &value, &fac, &fallback)) {
1358 if (
self->vec_num > 3) {
1359 PyErr_SetString(PyExc_ValueError,
"Vector must be 2D or 3D");
1364 other_vec, vec_num, vec_num, value,
"Vector.slerp(other), invalid 'other' arg") == -1) {
1372 if (
UNLIKELY((self_len_sq < FLT_EPSILON) || (other_len_sq < FLT_EPSILON))) {
1375 Py_INCREF(fallback);
1379 PyErr_SetString(PyExc_ValueError,
1381 "zero length vectors unsupported");
1389 if (
UNLIKELY(cosom < (-1.0f + FLT_EPSILON))) {
1392 Py_INCREF(fallback);
1396 PyErr_SetString(PyExc_ValueError,
1398 "opposite vectors unsupported");
1404 for (
x = 0;
x < vec_num;
x++) {
1405 ret_vec[
x] = (
w[0] * self_vec[
x]) + (
w[1] * other_vec[
x]);
1419 ".. function:: rotate(other)\n"
1421 " Rotate the vector by a rotation value.\n"
1423 " .. note:: 2D vectors are a special case that can only be rotated by a 2x2 matrix.\n"
1425 " :arg other: rotation component of mathutils value\n"
1426 " :type other: :class:`Euler`, :class:`Quaternion` or :class:`Matrix`\n");
1433 if (
self->vec_num == 2) {
1435 float other_rmat[2][2];
1445 float other_rmat[3][3];
1465 ".. method:: negate()\n"
1467 " Set all values to their negative.\n");
1487 ".. function:: copy()\n"
1489 " Returns a copy of this vector.\n"
1491 " :return: A copy of the vector.\n"
1492 " :rtype: :class:`Vector`\n"
1494 " .. note:: use this to get a copy of a wrapped vector with\n"
1495 " no reference to the original data.\n");
1520 PyObject *
ret, *tuple;
1527 ret = PyUnicode_FromFormat(
"Vector(%R)", tuple);
1532 #ifndef MATH_STANDALONE
1547 for (i = 0; i <
self->vec_num; i++) {
1563 static PyObject *
Vector_richcmpr(PyObject *objectA, PyObject *objectB,
int comparison_type)
1567 const double epsilon = 0.000001f;
1571 if (comparison_type == Py_NE) {
1584 if (vecA->
vec_num != vecB->vec_num) {
1585 if (comparison_type == Py_NE) {
1592 switch (comparison_type) {
1634 printf(
"The result of the comparison could not be evaluated");
1672 return self->vec_num;
1678 i =
self->vec_num - i;
1681 if (i < 0 || i >=
self->vec_num) {
1683 PyErr_Format(PyExc_AttributeError,
1684 "Vector.%c: unavailable on %dd vector",
1685 *(((
const char *)
"xyzw") + i),
1689 PyErr_SetString(PyExc_IndexError,
"vector[index]: out of range");
1698 return PyFloat_FromDouble(
self->vec[i]);
1715 if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
1717 PyErr_SetString(PyExc_TypeError,
1718 "vector[index] = x: "
1719 "assigned value not a number");
1724 i =
self->vec_num - i;
1727 if (i < 0 || i >=
self->vec_num) {
1729 PyErr_Format(PyExc_AttributeError,
1730 "Vector.%c = x: unavailable on %dd vector",
1731 *(((
const char *)
"xyzw") + i),
1735 PyErr_SetString(PyExc_IndexError,
1736 "vector[index] = x: "
1737 "assignment index out of range");
1741 self->vec[i] = scalar;
1767 end =
self->vec_num + end + 1;
1770 begin =
MIN2(begin, end);
1772 tuple = PyTuple_New(end - begin);
1774 PyTuple_SET_ITEM(tuple,
count - begin, PyFloat_FromDouble(
self->vec[
count]));
1792 begin =
MIN2(begin, end);
1794 vec_num = (end - begin);
1800 PyErr_SetString(PyExc_MemoryError,
1802 "problem allocating pointer space");
1807 memcpy(
self->vec + begin, vec, vec_num *
sizeof(
float));
1821 if (PyIndex_Check(item)) {
1823 i = PyNumber_AsSsize_t(item, PyExc_IndexError);
1824 if (i == -1 && PyErr_Occurred()) {
1832 if (PySlice_Check(item)) {
1833 Py_ssize_t start, stop, step, slicelength;
1835 if (PySlice_GetIndicesEx(item,
self->vec_num, &start, &stop, &step, &slicelength) < 0) {
1839 if (slicelength <= 0) {
1840 return PyTuple_New(0);
1846 PyErr_SetString(PyExc_IndexError,
"slice steps not supported with vectors");
1851 PyExc_TypeError,
"vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
1858 if (PyIndex_Check(item)) {
1859 Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
1860 if (i == -1 && PyErr_Occurred()) {
1868 if (PySlice_Check(item)) {
1869 Py_ssize_t start, stop, step, slicelength;
1871 if (PySlice_GetIndicesEx(item,
self->vec_num, &start, &stop, &step, &slicelength) < 0) {
1879 PyErr_SetString(PyExc_IndexError,
"slice steps not supported with vectors");
1884 PyExc_TypeError,
"vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
1901 PyErr_Format(PyExc_AttributeError,
1902 "Vector addition: (%s + %s) "
1903 "invalid type for this operation",
1904 Py_TYPE(
v1)->tp_name,
1905 Py_TYPE(
v2)->tp_name);
1916 if (vec1->
vec_num != vec2->vec_num) {
1917 PyErr_SetString(PyExc_AttributeError,
1919 "vectors must have the same dimensions for this operation");
1923 vec = PyMem_Malloc(vec1->
vec_num *
sizeof(
float));
1925 PyErr_SetString(PyExc_MemoryError,
1927 "problem allocating pointer space");
1942 PyErr_Format(PyExc_AttributeError,
1943 "Vector addition: (%s += %s) "
1944 "invalid type for this operation",
1945 Py_TYPE(
v1)->tp_name,
1946 Py_TYPE(
v2)->tp_name);
1952 if (vec1->
vec_num != vec2->vec_num) {
1953 PyErr_SetString(PyExc_AttributeError,
1955 "vectors must have the same dimensions for this operation");
1977 PyErr_Format(PyExc_AttributeError,
1978 "Vector subtraction: (%s - %s) "
1979 "invalid type for this operation",
1980 Py_TYPE(
v1)->tp_name,
1981 Py_TYPE(
v2)->tp_name);
1991 if (vec1->
vec_num != vec2->vec_num) {
1992 PyErr_SetString(PyExc_AttributeError,
1993 "Vector subtraction: "
1994 "vectors must have the same dimensions for this operation");
1998 vec = PyMem_Malloc(vec1->
vec_num *
sizeof(
float));
2000 PyErr_SetString(PyExc_MemoryError,
2002 "problem allocating pointer space");
2017 PyErr_Format(PyExc_AttributeError,
2018 "Vector subtraction: (%s -= %s) "
2019 "invalid type for this operation",
2020 Py_TYPE(
v1)->tp_name,
2021 Py_TYPE(
v2)->tp_name);
2027 if (vec1->
vec_num != vec2->vec_num) {
2028 PyErr_SetString(PyExc_AttributeError,
2029 "Vector subtraction: "
2030 "vectors must have the same dimensions for this operation");
2050 int row,
col,
z = 0;
2057 PyErr_SetString(PyExc_ValueError,
2059 "len(matrix.col) and len(vector) must be the same, "
2060 "except for 4x4 matrix * 3D vector.");
2065 memcpy(vec_cpy, vec->vec, vec->
vec_num *
sizeof(
float));
2069 for (row = 0; row < mat->
row_num; row++) {
2082 float *tvec = PyMem_Malloc(vec->
vec_num *
sizeof(
float));
2084 PyErr_SetString(PyExc_MemoryError,
2086 "problem allocating pointer space");
2096 float *tvec = PyMem_Malloc(vec1->
vec_num *
sizeof(
float));
2098 PyErr_SetString(PyExc_MemoryError,
2100 "problem allocating pointer space");
2131 if (vec1->
vec_num != vec2->vec_num) {
2132 PyErr_SetString(PyExc_ValueError,
2133 "Vector multiplication: "
2134 "vectors must have the same dimensions for this operation");
2142 if (((scalar = PyFloat_AsDouble(
v2)) == -1.0f && PyErr_Occurred()) == 0) {
2147 if (((scalar = PyFloat_AsDouble(
v1)) == -1.0f && PyErr_Occurred()) == 0) {
2152 PyErr_Format(PyExc_TypeError,
2153 "Element-wise multiplication: "
2154 "not supported between '%.200s' and '%.200s' types",
2155 Py_TYPE(
v1)->tp_name,
2156 Py_TYPE(
v2)->tp_name);
2186 if (vec1->
vec_num != vec2->vec_num) {
2187 PyErr_SetString(PyExc_ValueError,
2188 "Vector multiplication: "
2189 "vectors must have the same dimensions for this operation");
2196 else if (vec1 && (((scalar = PyFloat_AsDouble(
v2)) == -1.0f && PyErr_Occurred()) ==
2201 PyErr_Format(PyExc_TypeError,
2202 "In place element-wise multiplication: "
2203 "not supported between '%.200s' and '%.200s' types",
2204 Py_TYPE(
v1)->tp_name,
2205 Py_TYPE(
v2)->tp_name);
2237 if (vec1->
vec_num != vec2->vec_num) {
2238 PyErr_SetString(PyExc_ValueError,
2239 "Vector multiplication: "
2240 "vectors must have the same dimensions for this operation");
2270 PyErr_Format(PyExc_TypeError,
2271 "Vector multiplication: "
2272 "not supported between '%.200s' and '%.200s' types",
2273 Py_TYPE(
v1)->tp_name,
2274 Py_TYPE(
v2)->tp_name);
2281 PyErr_Format(PyExc_TypeError,
2282 "In place vector multiplication: "
2283 "not supported between '%.200s' and '%.200s' types",
2284 Py_TYPE(
v1)->tp_name,
2285 Py_TYPE(
v2)->tp_name);
2292 float *vec =
NULL, scalar;
2296 PyErr_SetString(PyExc_TypeError,
2298 "Vector must be divided by a float");
2307 if ((scalar = PyFloat_AsDouble(
v2)) == -1.0f && PyErr_Occurred()) {
2309 PyErr_SetString(PyExc_TypeError,
2311 "Vector must be divided by a float");
2315 if (scalar == 0.0f) {
2316 PyErr_SetString(PyExc_ZeroDivisionError,
2318 "divide by zero error");
2322 vec = PyMem_Malloc(vec1->
vec_num *
sizeof(
float));
2325 PyErr_SetString(PyExc_MemoryError,
2327 "problem allocating pointer space");
2346 if ((scalar = PyFloat_AsDouble(
v2)) == -1.0f && PyErr_Occurred()) {
2348 PyErr_SetString(PyExc_TypeError,
2350 "Vector must be divided by a float");
2354 if (scalar == 0.0f) {
2355 PyErr_SetString(PyExc_ZeroDivisionError,
2357 "divide by zero error");
2378 tvec = PyMem_Malloc(
self->vec_num *
sizeof(
float));
2457 PyDoc_STRVAR(Vector_axis_z_doc,
"Vector Z axis (3D Vectors only).\n\n:type: float");
2458 PyDoc_STRVAR(Vector_axis_w_doc,
"Vector W axis (4D Vectors only).\n\n:type: float");
2484 double dot = 0.0f, param;
2490 if ((param = PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) {
2491 PyErr_SetString(PyExc_TypeError,
"length must be set to a number");
2496 PyErr_SetString(PyExc_ValueError,
"cannot set a vectors length to a negative value");
2527 PyDoc_STRVAR(Vector_length_squared_doc,
"Vector length squared (v.dot(v)).\n\n:type: float");
2603 uint swizzleClosure;
2614 if (axis_from >=
self->vec_num) {
2615 PyErr_SetString(PyExc_AttributeError,
2617 "specified axis not present");
2621 vec[axis_to] =
self->vec[axis_from];
2648 uint swizzleClosure;
2664 if (axis_to >=
self->vec_num) {
2665 PyErr_SetString(PyExc_AttributeError,
2667 "specified axis not present");
2674 if (((scalarVal = PyFloat_AsDouble(value)) == -1 && PyErr_Occurred()) == 0) {
2678 vec_assign[i] = scalarVal;
2681 size_from = axis_from;
2683 else if (((
void)PyErr_Clear()),
2685 vec_assign, 2, 4, value,
"mathutils.Vector.**** = swizzle assignment")) == -1) {
2689 if (axis_from != size_from) {
2690 PyErr_SetString(PyExc_AttributeError,
"Vector swizzle: size does not match swizzle");
2701 memcpy(tvec,
self->vec,
self->vec_num *
sizeof(
float));
2705 tvec[axis_to] = vec_assign[axis_from];
2712 memcpy(
self->vec, tvec,
self->vec_num *
sizeof(
float));
2722 #define _SWIZZLE1(a) ((a) | SWIZZLE_VALID_AXIS)
2723 #define _SWIZZLE2(a, b) (_SWIZZLE1(a) | (((b) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS)))
2724 #define _SWIZZLE3(a, b, c) \
2725 (_SWIZZLE2(a, b) | (((c) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)))
2726 #define _SWIZZLE4(a, b, c, d) \
2727 (_SWIZZLE3(a, b, c) | (((d) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3)))
2729 #define SWIZZLE2(a, b) POINTER_FROM_INT(_SWIZZLE2(a, b))
2730 #define SWIZZLE3(a, b, c) POINTER_FROM_INT(_SWIZZLE3(a, b, c))
2731 #define SWIZZLE4(a, b, c, d) POINTER_FROM_INT(_SWIZZLE4(a, b, c, d))
2748 Vector_length_squared_doc,
3106 #undef AXIS_FROM_CHAR
3127 {
"Fill", (PyCFunction)
C_Vector_Fill, METH_VARARGS | METH_CLASS, C_Vector_Fill_doc},
3128 {
"Range", (PyCFunction)
C_Vector_Range, METH_VARARGS | METH_CLASS, C_Vector_Range_doc},
3129 {
"Linspace", (PyCFunction)
C_Vector_Linspace, METH_VARARGS | METH_CLASS, C_Vector_Linspace_doc},
3130 {
"Repeat", (PyCFunction)
C_Vector_Repeat, METH_VARARGS | METH_CLASS, C_Vector_Repeat_doc},
3133 {
"zero", (PyCFunction)
Vector_zero, METH_NOARGS, Vector_zero_doc},
3134 {
"negate", (PyCFunction)
Vector_negate, METH_NOARGS, Vector_negate_doc},
3137 {
"normalize", (PyCFunction)
Vector_normalize, METH_NOARGS, Vector_normalize_doc},
3138 {
"normalized", (PyCFunction)
Vector_normalized, METH_NOARGS, Vector_normalized_doc},
3140 {
"resize", (PyCFunction)
Vector_resize, METH_O, Vector_resize_doc},
3141 {
"resized", (PyCFunction)
Vector_resized, METH_O, Vector_resized_doc},
3142 {
"to_2d", (PyCFunction)
Vector_to_2d, METH_NOARGS, Vector_to_2d_doc},
3143 {
"resize_2d", (PyCFunction)
Vector_resize_2d, METH_NOARGS, Vector_resize_2d_doc},
3144 {
"to_3d", (PyCFunction)
Vector_to_3d, METH_NOARGS, Vector_to_3d_doc},
3145 {
"resize_3d", (PyCFunction)
Vector_resize_3d, METH_NOARGS, Vector_resize_3d_doc},
3146 {
"to_4d", (PyCFunction)
Vector_to_4d, METH_NOARGS, Vector_to_4d_doc},
3147 {
"resize_4d", (PyCFunction)
Vector_resize_4d, METH_NOARGS, Vector_resize_4d_doc},
3148 {
"to_tuple", (PyCFunction)
Vector_to_tuple, METH_VARARGS, Vector_to_tuple_doc},
3150 {
"orthogonal", (PyCFunction)
Vector_orthogonal, METH_NOARGS, Vector_orthogonal_doc},
3153 {
"reflect", (PyCFunction)
Vector_reflect, METH_O, Vector_reflect_doc},
3154 {
"cross", (PyCFunction)
Vector_cross, METH_O, Vector_cross_doc},
3155 {
"dot", (PyCFunction)
Vector_dot, METH_O, Vector_dot_doc},
3156 {
"angle", (PyCFunction)
Vector_angle, METH_VARARGS, Vector_angle_doc},
3157 {
"angle_signed", (PyCFunction)
Vector_angle_signed, METH_VARARGS, Vector_angle_signed_doc},
3158 {
"rotation_difference",
3161 Vector_rotation_difference_doc},
3162 {
"project", (PyCFunction)
Vector_project, METH_O, Vector_project_doc},
3163 {
"lerp", (PyCFunction)
Vector_lerp, METH_VARARGS, Vector_lerp_doc},
3164 {
"slerp", (PyCFunction)
Vector_slerp, METH_VARARGS, Vector_slerp_doc},
3165 {
"rotate", (PyCFunction)
Vector_rotate, METH_O, Vector_rotate_doc},
3170 {
"copy", (PyCFunction)
Vector_copy, METH_NOARGS, Vector_copy_doc},
3187 ".. class:: Vector(seq)\n"
3189 " This object gives access to Vectors in Blender.\n"
3191 " :param seq: Components of the vector, must be a sequence of at least two\n"
3192 " :type seq: sequence of numbers\n");
3194 PyVarObject_HEAD_INIT(
NULL, 0)
3219 #ifndef MATH_STANDALONE
3231 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
3290 PyErr_SetString(PyExc_RuntimeError,
"Vector(): invalid size");
3294 vec_alloc = PyMem_Malloc(vec_num *
sizeof(
float));
3296 PyErr_SetString(PyExc_MemoryError,
3298 "problem allocating data");
3304 self->vec = vec_alloc;
3305 self->vec_num = vec_num;
3308 self->cb_user =
NULL;
3309 self->cb_type =
self->cb_subtype = 0;
3312 memcpy(
self->vec, vec, vec_num *
sizeof(
float));
3317 self->vec[3] = 1.0f;
3323 PyMem_Free(vec_alloc);
3326 return (PyObject *)
self;
3334 PyErr_SetString(PyExc_RuntimeError,
"Vector(): invalid size");
3340 self->vec_num = vec_num;
3343 self->cb_user =
NULL;
3344 self->cb_type =
self->cb_subtype = 0;
3349 return (PyObject *)
self;
3357 self->cb_user = cb_user;
3358 self->cb_type = cb_type;
3359 self->cb_subtype = cb_subtype;
3360 PyObject_GC_Track(
self);
3363 return (PyObject *)
self;
3374 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 vec_to_quat(float q[4], const float vec[3], short axis, short upflag)
void interp_dot_slerp(float t, float cosom, float r_w[2])
void add_vn_vn(float *array_tar, const float *array_src, int size)
double len_squared_vn(const float *array, int size) ATTR_WARN_UNUSED_RESULT
void mul_vn_fl(float *array_tar, int size, float f)
void reflect_v3_v3v3(float out[3], const float vec[3], const float normal[3])
float normalize_vn(float *array_tar, int size)
void negate_vn(float *array_tar, int size)
MINLINE float normalize_v3(float r[3])
void range_vn_fl(float *array_tar, int size, float start, float step)
void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, int size)
void add_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, int size)
MINLINE void negate_v3_v3(float r[3], const float a[3])
void copy_vn_fl(float *array_tar, int size, float val)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
float normalize_vn_vn(float *array_tar, const float *array_src, int size)
void ortho_v3_v3(float out[3], const float v[3])
double dot_vn_vn(const float *array_src_a, const float *array_src_b, int size) ATTR_WARN_UNUSED_RESULT
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 mul_vn_vn(float *array_tar, const float *array_src, int size)
void ortho_v2_v2(float out[2], const float v[2])
void negate_vn_vn(float *array_tar, const float *array_src, int size)
MINLINE bool is_zero_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
void mul_vn_vn_fl(float *array_tar, const float *array_src, int size, float f)
void mul_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, int size)
void interp_vn_vn(float *array_tar, const float *array_src, float t, int size)
void sub_vn_vn(float *array_tar, const float *array_src, int size)
#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 Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
ATTR_WARN_UNUSED_RESULT const BMVert * v2
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SyclQueue void void size_t num_bytes void
ccl_device_inline float3 reflect(const float3 incident, const float3 normal)
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)
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
char BaseMathObject_is_valid_doc[]
PyObject * BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure))
char BaseMathObject_is_wrapped_doc[]
char BaseMathObject_is_frozen_doc[]
int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix)
PyObject * BaseMathObject_is_valid_get(BaseMathObject *self, void *UNUSED(closure))
char BaseMathObject_owner_doc[]
char BaseMathObject_freeze_doc[]
int mathutils_array_parse_alloc(float **array, int array_num, PyObject *value, const char *error_prefix)
int BaseMathObject_clear(BaseMathObject *self)
int BaseMathObject_traverse(BaseMathObject *self, visitproc visit, void *arg)
#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")
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)
static PyObject * Vector_to_tuple_ex(VectorObject *self, int ndigits)
#define SWIZZLE_VALID_AXIS
PyObject * Vector_CreatePyObject_wrap(float *vec, const int vec_num, PyTypeObject *base_type)
static PyObject * Vector_dot(VectorObject *self, PyObject *value)
static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *value)
PyObject * Vector_CreatePyObject_alloc(float *vec, const int vec_num, PyTypeObject *base_type)
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)
static PyObject * Vector_slerp(VectorObject *self, PyObject *args)
PyObject * Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObject *base_type)
static PyObject * Vector_mul(PyObject *v1, PyObject *v2)
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)
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int vec_num, uchar cb_type, uchar cb_subtype)
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)
static PyGetSetDef Vector_getseters[]
static PyObject * Vector_sub(PyObject *v1, PyObject *v2)
static int Vector_axis_set(VectorObject *self, PyObject *value, void *type)
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)