| 1223 | " :return: angle in radians or fallback when given\n" |
| 1224 | " :rtype: float | Any\n"); |
| 1225 | static PyObject *Vector_angle_signed(VectorObject *self, PyObject *args) |
| 1226 | { |
| 1227 | float tvec[2]; |
| 1228 | |
| 1229 | PyObject *value; |
| 1230 | PyObject *fallback = nullptr; |
| 1231 | |
| 1232 | if (!PyArg_ParseTuple(args, "O|O:angle_signed", &value, &fallback)) { |
| 1233 | return nullptr; |
| 1234 | } |
| 1235 | |
| 1236 | if (BaseMath_ReadCallback(self) == -1) { |
| 1237 | return nullptr; |
| 1238 | } |
| 1239 | |
| 1240 | if (mathutils_array_parse( |
| 1241 | tvec, 2, 2, value, "Vector.angle_signed(other), invalid 'other' arg") == -1) |
| 1242 | { |
| 1243 | return nullptr; |
| 1244 | } |
| 1245 | |
| 1246 | if (self->vec_num != 2) { |
| 1247 | PyErr_SetString(PyExc_ValueError, "Vector must be 2D"); |
| 1248 | return nullptr; |
| 1249 | } |
| 1250 | |
| 1251 | if (is_zero_v2(self->vec) || is_zero_v2(tvec)) { |
| 1252 | /* avoid exception */ |
| 1253 | if (fallback) { |
| 1254 | Py_INCREF(fallback); |
| 1255 | return fallback; |
| 1256 | } |
| 1257 | |
| 1258 | PyErr_SetString(PyExc_ValueError, |
| 1259 | "Vector.angle_signed(other): " |
| 1260 | "zero length vectors have no valid angle"); |
| 1261 | return nullptr; |
| 1262 | } |
| 1263 | |
| 1264 | return PyFloat_FromDouble(angle_signed_v2v2(self->vec, tvec)); |
| 1265 | } |
| 1266 | |
| 1267 | /** \} */ |
| 1268 |
nothing calls this directly
no test coverage detected