MCPcopy Create free account
hub / github.com/blender/blender / Vector_cross

Function Vector_cross

source/blender/python/mathutils/mathutils_Vector.cc:1061–1091  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1059 "\n"
1060 " .. note:: both vectors must be 2D or 3D\n");
1061static PyObject *Vector_cross(VectorObject *self, PyObject *value)
1062{
1063 PyObject *ret;
1064 float tvec[3];
1065
1066 if (BaseMath_ReadCallback(self) == -1) {
1067 return nullptr;
1068 }
1069
1070 if (self->vec_num > 3) {
1071 PyErr_SetString(PyExc_ValueError, "Vector must be 2D or 3D");
1072 return nullptr;
1073 }
1074
1075 if (mathutils_array_parse(
1076 tvec, self->vec_num, self->vec_num, value, "Vector.cross(other), invalid 'other' arg") ==
1077 -1)
1078 {
1079 return nullptr;
1080 }
1081
1082 if (self->vec_num == 3) {
1083 ret = Vector_CreatePyObject(nullptr, 3, Py_TYPE(self));
1084 cross_v3_v3v3((reinterpret_cast<VectorObject *>(ret))->vec, self->vec, tvec);
1085 }
1086 else {
1087 /* size == 2 */
1088 ret = PyFloat_FromDouble(cross_v2v2(self->vec, tvec));
1089 }
1090 return ret;
1091}
1092
1093/** \} */
1094

Callers

nothing calls this directly

Calls 4

mathutils_array_parseFunction · 0.85
Vector_CreatePyObjectFunction · 0.85
cross_v3_v3v3Function · 0.85
cross_v2v2Function · 0.85

Tested by

no test coverage detected