| 1004 | " :return: The reflected vector matching the size of this vector.\n" |
| 1005 | " :rtype: :class:`Vector`\n"); |
| 1006 | static PyObject *Vector_reflect(VectorObject *self, PyObject *value) |
| 1007 | { |
| 1008 | int value_num; |
| 1009 | float mirror[3], vec[3]; |
| 1010 | float reflect[3] = {0.0f}; |
| 1011 | float tvec[MAX_DIMENSIONS]; |
| 1012 | |
| 1013 | if (BaseMath_ReadCallback(self) == -1) { |
| 1014 | return nullptr; |
| 1015 | } |
| 1016 | |
| 1017 | if ((value_num = mathutils_array_parse( |
| 1018 | tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) |
| 1019 | { |
| 1020 | return nullptr; |
| 1021 | } |
| 1022 | |
| 1023 | if (self->vec_num < 2 || self->vec_num > 4) { |
| 1024 | PyErr_SetString(PyExc_ValueError, "Vector must be 2D, 3D or 4D"); |
| 1025 | return nullptr; |
| 1026 | } |
| 1027 | |
| 1028 | mirror[0] = tvec[0]; |
| 1029 | mirror[1] = tvec[1]; |
| 1030 | mirror[2] = (value_num > 2) ? tvec[2] : 0.0f; |
| 1031 | |
| 1032 | vec[0] = self->vec[0]; |
| 1033 | vec[1] = self->vec[1]; |
| 1034 | vec[2] = (value_num > 2) ? self->vec[2] : 0.0f; |
| 1035 | |
| 1036 | normalize_v3(mirror); |
| 1037 | reflect_v3_v3v3(reflect, vec, mirror); |
| 1038 | |
| 1039 | return Vector_CreatePyObject(reflect, self->vec_num, Py_TYPE(self)); |
| 1040 | } |
| 1041 | |
| 1042 | /** \} */ |
| 1043 |
nothing calls this directly
no test coverage detected