| 1331 | " :return: the parallel projection vector\n" |
| 1332 | " :rtype: :class:`Vector`\n"); |
| 1333 | static PyObject *Vector_project(VectorObject *self, PyObject *value) |
| 1334 | { |
| 1335 | const int vec_num = self->vec_num; |
| 1336 | float *tvec; |
| 1337 | double dot = 0.0f, dot2 = 0.0f; |
| 1338 | int x; |
| 1339 | |
| 1340 | if (BaseMath_ReadCallback(self) == -1) { |
| 1341 | return nullptr; |
| 1342 | } |
| 1343 | |
| 1344 | if (mathutils_array_parse_alloc( |
| 1345 | &tvec, vec_num, value, "Vector.project(other), invalid 'other' arg") == -1) |
| 1346 | { |
| 1347 | return nullptr; |
| 1348 | } |
| 1349 | |
| 1350 | /* get dot products */ |
| 1351 | for (x = 0; x < vec_num; x++) { |
| 1352 | dot += double(self->vec[x] * tvec[x]); |
| 1353 | dot2 += double(tvec[x] * tvec[x]); |
| 1354 | } |
| 1355 | /* projection */ |
| 1356 | dot /= dot2; |
| 1357 | for (x = 0; x < vec_num; x++) { |
| 1358 | tvec[x] *= float(dot); |
| 1359 | } |
| 1360 | return Vector_CreatePyObject_alloc(tvec, vec_num, Py_TYPE(self)); |
| 1361 | } |
| 1362 | |
| 1363 | /** \} */ |
| 1364 |
nothing calls this directly
no test coverage detected