15#ifndef MATH_STANDALONE
42 M_Geometry_intersect_ray_tri_doc,
43 ".. function:: intersect_ray_tri(v1, v2, v3, ray, orig, clip=True, /)\n"
45 " Returns the intersection between a ray and a triangle, if possible, returns None "
48 " :param v1: Point1\n"
49 " :type v1: :class:`mathutils.Vector`\n"
50 " :param v2: Point2\n"
51 " :type v2: :class:`mathutils.Vector`\n"
52 " :param v3: Point3\n"
53 " :type v3: :class:`mathutils.Vector`\n"
54 " :param ray: Direction of the ray\n"
55 " :type ray: :class:`mathutils.Vector`\n"
56 " :param orig: Origin\n"
57 " :type orig: :class:`mathutils.Vector`\n"
58 " :param clip: When False, don't restrict the intersection to the area of the "
59 "triangle, use the infinite plane defined by the triangle.\n"
61 " :return: The point of intersection or None if no intersection is found\n"
62 " :rtype: :class:`mathutils.Vector` | None\n");
65 const char *error_prefix =
"intersect_ray_tri";
66 PyObject *py_ray, *py_ray_off, *py_tri[3];
67 float dir[3], orig[3], tri[3][3], e1[3], e2[3], pvec[3], tvec[3], qvec[3];
68 float det, inv_det, u,
v, t;
72 if (!PyArg_ParseTuple(args,
118 if (det > -0.000001f && det < 0.000001f) {
122 inv_det = 1.0f / det;
129 if (clip && (u < 0.0f || u > 1.0f)) {
161 M_Geometry_intersect_line_line_doc,
162 ".. function:: intersect_line_line(v1, v2, v3, v4, /)\n"
164 " Returns a tuple with the points on each line respectively closest to the other.\n"
166 " :param v1: First point of the first line\n"
167 " :type v1: :class:`mathutils.Vector`\n"
168 " :param v2: Second point of the first line\n"
169 " :type v2: :class:`mathutils.Vector`\n"
170 " :param v3: First point of the second line\n"
171 " :type v3: :class:`mathutils.Vector`\n"
172 " :param v4: Second point of the second line\n"
173 " :type v4: :class:`mathutils.Vector`\n"
174 " :return: The intersection on each line or None when the lines are parallel.\n"
175 " :rtype: tuple[:class:`mathutils.Vector`, :class:`mathutils.Vector`] | None\n");
178 const char *error_prefix =
"intersect_line_line";
180 PyObject *py_lines[4];
181 float lines[4][3], i1[3], i2[3];
185 if (!PyArg_ParseTuple(args,
190 ":intersect_line_line",
202 error_prefix) != -1) &&
207 error_prefix) != -1) &&
212 error_prefix) != -1)) == 0)
218 if (ix_vec_num == 2) {
236 tuple = PyTuple_New(2);
247 M_Geometry_intersect_sphere_sphere_2d_doc,
248 ".. function:: intersect_sphere_sphere_2d(p_a, radius_a, p_b, radius_b, /)\n"
250 " Returns the 2 intersection points of two circles.\n"
252 " :param p_a: Center of the first circle\n"
253 " :type p_a: :class:`mathutils.Vector`\n"
254 " :param radius_a: Radius of the first circle\n"
255 " :type radius_a: float\n"
256 " :param p_b: Center of the second circle\n"
257 " :type p_b: :class:`mathutils.Vector`\n"
258 " :param radius_b: Radius of the second circle\n"
259 " :type radius_b: float\n"
260 " :return: The 2 intersection points or None when there is no intersection.\n"
261 " :rtype: tuple[:class:`mathutils.Vector`, :class:`mathutils.Vector`] | "
262 "tuple[None, None]\n");
265 const char *error_prefix =
"intersect_sphere_sphere_2d";
267 PyObject *py_v_a, *py_v_b;
268 float v_a[2], v_b[2];
273 if (!PyArg_ParseTuple(args,
278 ":intersect_sphere_sphere_2d",
293 ret = PyTuple_New(2);
299 (dist > rad_a + rad_b) ||
301 (dist <
fabsf(rad_a - rad_b)) ||
309 const float dist_delta = ((rad_a * rad_a) - (rad_b * rad_b) + (dist * dist)) / (2.0f * dist);
310 const float h =
powf(
fabsf((rad_a * rad_a) - (dist_delta * dist_delta)), 0.5f);
314 i_cent[0] = v_a[0] + ((v_ab[0] * dist_delta) / dist);
315 i_cent[1] = v_a[1] + ((v_ab[1] * dist_delta) / dist);
317 i1[0] = i_cent[0] + h * v_ab[1] / dist;
318 i1[1] = i_cent[1] - h * v_ab[0] / dist;
320 i2[0] = i_cent[0] - h * v_ab[1] / dist;
321 i2[1] = i_cent[1] + h * v_ab[0] / dist;
332 M_Geometry_intersect_tri_tri_2d_doc,
333 ".. function:: intersect_tri_tri_2d(tri_a1, tri_a2, tri_a3, tri_b1, tri_b2, tri_b3, /)\n"
335 " Check if two 2D triangles intersect.\n"
337 " :param tri_a1: First vertex of the first triangle.\n"
338 " :type tri_a1: :class:`mathutils.Vector`\n"
339 " :param tri_a2: Second vertex of the first triangle.\n"
340 " :type tri_a2: :class:`mathutils.Vector`\n"
341 " :param tri_a3: Third vertex of the first triangle.\n"
342 " :type tri_a3: :class:`mathutils.Vector`\n"
343 " :param tri_b1: First vertex of the second triangle.\n"
344 " :type tri_b1: :class:`mathutils.Vector`\n"
345 " :param tri_b2: Second vertex of the second triangle.\n"
346 " :type tri_b2: :class:`mathutils.Vector`\n"
347 " :param tri_b3: Third vertex of the second triangle.\n"
348 " :type tri_b3: :class:`mathutils.Vector`\n"
349 " :return: True if the triangles intersect.\n"
353 const char *error_prefix =
"intersect_tri_tri_2d";
354 PyObject *tri_pair_py[2][3];
355 float tri_pair[2][3][2];
357 if (!PyArg_ParseTuple(args,
364 ":intersect_tri_tri_2d",
375 for (
int i = 0; i < 2; i++) {
376 for (
int j = 0; j < 3; j++) {
378 tri_pair[i][j], 2, 2 |
MU_ARRAY_SPILL, tri_pair_py[i][j], error_prefix) == -1)
386 return PyBool_FromLong(
ret);
391 M_Geometry_normal_doc,
392 ".. function:: normal(*vectors)\n"
394 " Returns the normal of a 3D polygon.\n"
396 " :param vectors: 3 or more vectors to calculate normals.\n"
397 " :type vectors: Sequence[Sequence[float]]\n"
398 " :return: The normal vector.\n"
399 " :rtype: :class:`mathutils.Vector`\n");
405 PyObject *
ret =
nullptr;
408 if (PyTuple_GET_SIZE(args) == 1) {
409 args = PyTuple_GET_ITEM(args, 0);
413 reinterpret_cast<float **
>(&coords), 3 |
MU_ARRAY_SPILL, args,
"normal")) == -1)
418 if (coords_len < 3) {
419 PyErr_SetString(PyExc_ValueError,
"Expected 3 or more vectors");
434 M_Geometry_area_tri_doc,
435 ".. function:: area_tri(v1, v2, v3, /)\n"
437 " Returns the area of the 2D or 3D triangle defined.\n"
439 " :param v1: Point1\n"
440 " :type v1: :class:`mathutils.Vector`\n"
441 " :param v2: Point2\n"
442 " :type v2: :class:`mathutils.Vector`\n"
443 " :param v3: Point3\n"
444 " :type v3: :class:`mathutils.Vector`\n"
445 " :return: The area of the triangle.\n"
449 const char *error_prefix =
"area_tri";
454 if (!PyArg_ParseTuple(args,
476 M_Geometry_volume_tetrahedron_doc,
477 ".. function:: volume_tetrahedron(v1, v2, v3, v4, /)\n"
479 " Return the absolute (unsigned) volume formed by a tetrahedron "
480 "(points can be in any order).\n"
482 " :param v1: Point1\n"
483 " :type v1: :class:`mathutils.Vector`\n"
484 " :param v2: Point2\n"
485 " :type v2: :class:`mathutils.Vector`\n"
486 " :param v3: Point3\n"
487 " :type v3: :class:`mathutils.Vector`\n"
488 " :param v4: Point4\n"
489 " :type v4: :class:`mathutils.Vector`\n"
490 " :return: The volume of the tetrahedron.\n"
494 const char *error_prefix =
"volume_tetrahedron";
499 if (!PyArg_ParseTuple(args,
504 ":volume_tetrahedron",
521 M_Geometry_intersect_line_line_2d_doc,
522 ".. function:: intersect_line_line_2d(lineA_p1, lineA_p2, lineB_p1, lineB_p2, /)\n"
524 " Takes 2 segments (defined by 4 vectors) and returns a vector for their point of "
525 "intersection or None.\n"
527 " .. warning:: Despite its name, this function works on segments, and not on lines.\n"
529 " :param lineA_p1: First point of the first segment\n"
530 " :type lineA_p1: :class:`mathutils.Vector`\n"
531 " :param lineA_p2: Second point of the first segment\n"
532 " :type lineA_p2: :class:`mathutils.Vector`\n"
533 " :param lineB_p1: First point of the second segment\n"
534 " :type lineB_p1: :class:`mathutils.Vector`\n"
535 " :param lineB_p2: Second point of the second segment\n"
536 " :type lineB_p2: :class:`mathutils.Vector`\n"
537 " :return: The point of intersection or None when not found\n"
538 " :rtype: :class:`mathutils.Vector` | None\n");
541 const char *error_prefix =
"intersect_line_line_2d";
542 PyObject *py_lines[4];
547 if (!PyArg_ParseTuple(args,
552 ":intersect_line_line_2d",
573 M_Geometry_intersect_line_plane_doc,
574 ".. function:: intersect_line_plane(line_a, line_b, plane_co, plane_no, no_flip=False, /)\n"
576 " Calculate the intersection between a line (as 2 vectors) and a plane.\n"
577 " Returns a vector for the intersection or None.\n"
579 " :param line_a: First point of the line\n"
580 " :type line_a: :class:`mathutils.Vector`\n"
581 " :param line_b: Second point of the line\n"
582 " :type line_b: :class:`mathutils.Vector`\n"
583 " :param plane_co: A point on the plane\n"
584 " :type plane_co: :class:`mathutils.Vector`\n"
585 " :param plane_no: The direction the plane is facing\n"
586 " :type plane_no: :class:`mathutils.Vector`\n"
587 " :param no_flip: Currently ignored.\n"
588 " :type no_flip: bool\n"
589 " :return: The point of intersection or None when not found\n"
590 " :rtype: :class:`mathutils.Vector` | None\n");
593 const char *error_prefix =
"intersect_line_plane";
594 PyObject *py_line_a, *py_line_b, *py_plane_co, *py_plane_no;
595 float line_a[3], line_b[3], plane_co[3], plane_no[3];
597 const bool no_flip =
false;
599 if (!PyArg_ParseTuple(args,
606 ":intersect_line_plane",
636 M_Geometry_intersect_plane_plane_doc,
637 ".. function:: intersect_plane_plane(plane_a_co, plane_a_no, plane_b_co, plane_b_no, /)\n"
639 " Return the intersection between two planes\n"
641 " :param plane_a_co: Point on the first plane\n"
642 " :type plane_a_co: :class:`mathutils.Vector`\n"
643 " :param plane_a_no: Normal of the first plane\n"
644 " :type plane_a_no: :class:`mathutils.Vector`\n"
645 " :param plane_b_co: Point on the second plane\n"
646 " :type plane_b_co: :class:`mathutils.Vector`\n"
647 " :param plane_b_no: Normal of the second plane\n"
648 " :type plane_b_no: :class:`mathutils.Vector`\n"
649 " :return: The line of the intersection represented as a point and a vector or None if the "
650 "intersection can't be calculated\n"
651 " :rtype: tuple[:class:`mathutils.Vector`, :class:`mathutils.Vector`] | "
652 "tuple[None, None]\n");
655 const char *error_prefix =
"intersect_plane_plane";
656 PyObject *
ret, *ret_co, *ret_no;
657 PyObject *py_plane_a_co, *py_plane_a_no, *py_plane_b_co, *py_plane_b_no;
658 float plane_a_co[3], plane_a_no[3], plane_b_co[3], plane_b_no[3];
659 float plane_a[4], plane_b[4];
664 if (!PyArg_ParseTuple(args,
669 ":intersect_plane_plane",
700 ret_co = Py_NewRef(Py_None);
701 ret_no = Py_NewRef(Py_None);
704 ret = PyTuple_New(2);
711 M_Geometry_intersect_line_sphere_doc,
712 ".. function:: intersect_line_sphere(line_a, line_b, sphere_co, sphere_radius, clip=True, /)\n"
714 " Takes a line (as 2 points) and a sphere (as a point and a radius) and\n"
715 " returns the intersection\n"
717 " :param line_a: First point of the line\n"
718 " :type line_a: :class:`mathutils.Vector`\n"
719 " :param line_b: Second point of the line\n"
720 " :type line_b: :class:`mathutils.Vector`\n"
721 " :param sphere_co: The center of the sphere\n"
722 " :type sphere_co: :class:`mathutils.Vector`\n"
723 " :param sphere_radius: Radius of the sphere\n"
724 " :type sphere_radius: float\n"
725 " :param clip: When False, don't restrict the intersection to the line segment.\n"
726 " :type clip: bool\n"
727 " :return: The intersection points as a pair of vectors "
728 "(each is None when not found).\n"
729 " :rtype: tuple[:class:`mathutils.Vector` | None, :class:`mathutils.Vector` | None]\n");
732 const char *error_prefix =
"intersect_line_sphere";
733 PyObject *py_line_a, *py_line_b, *py_sphere_co;
734 float line_a[3], line_b[3], sphere_co[3];
741 if (!PyArg_ParseTuple(args,
748 ":intersect_line_sphere",
771 PyObject *
ret = PyTuple_New(2);
810 M_Geometry_intersect_line_sphere_2d_doc,
811 ".. function:: intersect_line_sphere_2d(line_a, line_b, sphere_co, "
812 "sphere_radius, clip=True, /)\n"
814 " Takes a line (as 2 points) and a circle (as a point and a radius) and\n"
815 " returns the intersection\n"
817 " :param line_a: First point of the line\n"
818 " :type line_a: :class:`mathutils.Vector`\n"
819 " :param line_b: Second point of the line\n"
820 " :type line_b: :class:`mathutils.Vector`\n"
821 " :param sphere_co: The center of the circle\n"
822 " :type sphere_co: :class:`mathutils.Vector`\n"
823 " :param sphere_radius: Radius of the circle\n"
824 " :type sphere_radius: float\n"
825 " :param clip: When False, don't restrict the intersection to the line segment.\n"
826 " :type clip: bool\n"
827 " :return: The intersection points as a pair of vectors "
828 "(each is None when not found).\n"
829 " :rtype: tuple[:class:`mathutils.Vector` | None, :class:`mathutils.Vector` | None]\n");
832 const char *error_prefix =
"intersect_line_sphere_2d";
833 PyObject *py_line_a, *py_line_b, *py_sphere_co;
834 float line_a[2], line_b[2], sphere_co[2];
841 if (!PyArg_ParseTuple(args,
848 ":intersect_line_sphere_2d",
871 PyObject *
ret = PyTuple_New(2);
909 M_Geometry_intersect_point_line_doc,
910 ".. function:: intersect_point_line(pt, line_p1, line_p2, /)\n"
912 " Takes a point and a line and returns the closest point on the line and its "
913 "parametric distance from the first point of the line. "
914 "A value of 0.0 is the first point, 1.0 is the second, "
915 "values outside [0, 1] are extrapolated.\n"
917 " :param pt: Point\n"
918 " :type pt: :class:`mathutils.Vector`\n"
919 " :param line_p1: First point of the line\n"
920 " :type line_p1: :class:`mathutils.Vector`\n"
921 " :param line_p2: Second point of the line\n"
922 " :type line_p2: :class:`mathutils.Vector`\n"
923 " :return: The closest point on the line and its parametric distance from the first point.\n"
924 " :rtype: tuple[:class:`mathutils.Vector`, float]\n");
926 PyObject *
const *args,
929 const char *error_prefix =
"intersect_point_line";
930 float pt[3], pt_out[3], line_a[3], line_b[3];
937 PyObject *py_pt = args[0];
938 PyObject *py_line_a = args[1];
939 PyObject *py_line_b = args[2];
955 PyObject *
ret = PyTuple_New(2);
963 M_Geometry_intersect_point_line_segment_doc,
964 ".. function:: intersect_point_line_segment(pt, seg_p1, seg_p2, /)\n"
966 " Takes a point and a segment and returns the closest point on the segment "
967 "and the distance to the segment.\n"
969 " :param pt: Point\n"
970 " :type pt: :class:`mathutils.Vector`\n"
971 " :param seg_p1: First point of the segment\n"
972 " :type seg_p1: :class:`mathutils.Vector`\n"
973 " :param seg_p2: Second point of the segment\n"
974 " :type seg_p2: :class:`mathutils.Vector`\n"
975 " :return: The closest point on the segment and the distance to the segment.\n"
976 " :rtype: tuple[:class:`mathutils.Vector`, float]\n");
978 PyObject *
const *args,
981 const char *error_prefix =
"intersect_point_line_segment";
982 float pt[3], pt_out[3], seg_a[3], seg_b[3];
989 PyObject *py_pt = args[0];
990 PyObject *py_seq_a = args[1];
991 PyObject *py_seg_b = args[2];
1006 const float lambda =
len_v3v3(pt_out, pt);
1008 PyObject *
ret = PyTuple_New(2);
1016 M_Geometry_intersect_point_tri_doc,
1017 ".. function:: intersect_point_tri(pt, tri_p1, tri_p2, tri_p3, /)\n"
1019 " Takes 4 vectors: one is the point and the next 3 define the triangle. Projects "
1020 "the point onto the triangle plane and checks if it is within the triangle.\n"
1022 " :param pt: Point\n"
1023 " :type pt: :class:`mathutils.Vector`\n"
1024 " :param tri_p1: First point of the triangle\n"
1025 " :type tri_p1: :class:`mathutils.Vector`\n"
1026 " :param tri_p2: Second point of the triangle\n"
1027 " :type tri_p2: :class:`mathutils.Vector`\n"
1028 " :param tri_p3: Third point of the triangle\n"
1029 " :type tri_p3: :class:`mathutils.Vector`\n"
1030 " :return: Point on the triangle's plane or None if it's outside the triangle\n"
1031 " :rtype: :class:`mathutils.Vector` | None\n");
1034 const char *error_prefix =
"intersect_point_tri";
1035 PyObject *py_pt, *py_tri[3];
1036 float pt[3], tri[3][3];
1040 if (!PyArg_ParseTuple(args,
1045 ":intersect_point_tri",
1073 M_Geometry_closest_point_on_tri_doc,
1074 ".. function:: closest_point_on_tri(pt, tri_p1, tri_p2, tri_p3, /)\n"
1076 " Takes 4 vectors: one is the point and the next 3 define the triangle.\n"
1078 " :param pt: Point\n"
1079 " :type pt: :class:`mathutils.Vector`\n"
1080 " :param tri_p1: First point of the triangle\n"
1081 " :type tri_p1: :class:`mathutils.Vector`\n"
1082 " :param tri_p2: Second point of the triangle\n"
1083 " :type tri_p2: :class:`mathutils.Vector`\n"
1084 " :param tri_p3: Third point of the triangle\n"
1085 " :type tri_p3: :class:`mathutils.Vector`\n"
1086 " :return: The closest point of the triangle.\n"
1087 " :rtype: :class:`mathutils.Vector`\n");
1090 const char *error_prefix =
"closest_point_on_tri";
1091 PyObject *py_pt, *py_tri[3];
1092 float pt[3], tri[3][3];
1096 if (!PyArg_ParseTuple(args,
1101 ":closest_point_on_tri",
1127 M_Geometry_intersect_point_tri_2d_doc,
1128 ".. function:: intersect_point_tri_2d(pt, tri_p1, tri_p2, tri_p3, /)\n"
1130 " Takes 4 vectors (using only the x and y coordinates): one is the point and the next 3 "
1131 "define the triangle. Returns a non-zero value if the point is within the triangle, otherwise "
1134 " :param pt: Point\n"
1135 " :type pt: :class:`mathutils.Vector`\n"
1136 " :param tri_p1: First point of the triangle\n"
1137 " :type tri_p1: :class:`mathutils.Vector`\n"
1138 " :param tri_p2: Second point of the triangle\n"
1139 " :type tri_p2: :class:`mathutils.Vector`\n"
1140 " :param tri_p3: Third point of the triangle\n"
1141 " :type tri_p3: :class:`mathutils.Vector`\n"
1142 " :return: 1 if inside with CCW winding, -1 if inside with CW winding, otherwise 0.\n"
1146 const char *error_prefix =
"intersect_point_tri_2d";
1147 PyObject *py_pt, *py_tri[3];
1148 float pt[2], tri[3][2];
1151 if (!PyArg_ParseTuple(args,
1156 ":intersect_point_tri_2d",
1177 M_Geometry_intersect_point_quad_2d_doc,
1178 ".. function:: intersect_point_quad_2d(pt, quad_p1, quad_p2, quad_p3, quad_p4, /)\n"
1180 " Takes 5 vectors (using only the x and y coordinates): one is the point and the "
1181 "next 4 define the quad,\n"
1182 " only the x and y are used from the vectors. Returns a non-zero value if the point is "
1183 "within the quad, otherwise 0.\n"
1184 " Works only with convex quads without singular edges.\n"
1186 " :param pt: Point\n"
1187 " :type pt: :class:`mathutils.Vector`\n"
1188 " :param quad_p1: First point of the quad\n"
1189 " :type quad_p1: :class:`mathutils.Vector`\n"
1190 " :param quad_p2: Second point of the quad\n"
1191 " :type quad_p2: :class:`mathutils.Vector`\n"
1192 " :param quad_p3: Third point of the quad\n"
1193 " :type quad_p3: :class:`mathutils.Vector`\n"
1194 " :param quad_p4: Fourth point of the quad\n"
1195 " :type quad_p4: :class:`mathutils.Vector`\n"
1196 " :return: 1 if inside with CCW winding, -1 if inside with CW winding, otherwise 0.\n"
1200 const char *error_prefix =
"intersect_point_quad_2d";
1201 PyObject *py_pt, *py_quad[4];
1202 float pt[2], quad[4][2];
1205 if (!PyArg_ParseTuple(args,
1211 ":intersect_point_quad_2d",
1232 M_Geometry_distance_point_to_plane_doc,
1233 ".. function:: distance_point_to_plane(pt, plane_co, plane_no, /)\n"
1235 " Returns the signed distance between a point and a plane "
1236 "(negative when below the normal).\n"
1238 " :param pt: Point\n"
1239 " :type pt: :class:`mathutils.Vector`\n"
1240 " :param plane_co: A point on the plane\n"
1241 " :type plane_co: :class:`mathutils.Vector`\n"
1242 " :param plane_no: The direction the plane is facing\n"
1243 " :type plane_no: :class:`mathutils.Vector`\n"
1244 " :return: The signed distance.\n"
1245 " :rtype: float\n");
1248 const char *error_prefix =
"distance_point_to_plane";
1249 PyObject *py_pt, *py_plane_co, *py_plane_no;
1250 float pt[3], plane_co[3], plane_no[3];
1253 if (!PyArg_ParseTuple(args,
1257 ":distance_point_to_plane",
1279 M_Geometry_barycentric_transform_doc,
1280 ".. function:: barycentric_transform(point, tri_a1, tri_a2, tri_a3, tri_b1, tri_b2, tri_b3, "
1283 " Return a transformed point, the transformation is defined by 2 triangles.\n"
1285 " :param point: The point to transform.\n"
1286 " :type point: :class:`mathutils.Vector`\n"
1287 " :param tri_a1: source triangle vertex.\n"
1288 " :type tri_a1: :class:`mathutils.Vector`\n"
1289 " :param tri_a2: source triangle vertex.\n"
1290 " :type tri_a2: :class:`mathutils.Vector`\n"
1291 " :param tri_a3: source triangle vertex.\n"
1292 " :type tri_a3: :class:`mathutils.Vector`\n"
1293 " :param tri_b1: target triangle vertex.\n"
1294 " :type tri_b1: :class:`mathutils.Vector`\n"
1295 " :param tri_b2: target triangle vertex.\n"
1296 " :type tri_b2: :class:`mathutils.Vector`\n"
1297 " :param tri_b3: target triangle vertex.\n"
1298 " :type tri_b3: :class:`mathutils.Vector`\n"
1299 " :return: The transformed point\n"
1300 " :rtype: :class:`mathutils.Vector`\n");
1303 const char *error_prefix =
"barycentric_transform";
1304 PyObject *py_pt_src, *py_tri_src[3], *py_tri_dst[3];
1305 float pt_src[3], pt_dst[3], tri_src[3][3], tri_dst[3][3];
1308 if (!PyArg_ParseTuple(args,
1316 ":barycentric_transform",
1358 M_Geometry_points_in_planes_doc,
1359 ".. function:: points_in_planes(planes, epsilon_coplanar=1e-4, epsilon_isect=1e-6, /)\n"
1361 " Returns a list of points inside all planes given and a list of index values for "
1362 "the planes used.\n"
1364 " :param planes: List of planes (4D vectors).\n"
1365 " :type planes: list[:class:`mathutils.Vector`]\n"
1366 " :param epsilon_coplanar: Epsilon value for interpreting plane pairs as co-planar.\n"
1367 " :type epsilon_coplanar: float\n"
1368 " :param epsilon_isect: Epsilon value for intersection.\n"
1369 " :type epsilon_isect: float\n"
1370 " :return: Two lists, one containing the 3D coordinates inside the planes, "
1371 "another containing the plane indices used.\n"
1372 " :rtype: tuple[list[:class:`mathutils.Vector`], list[int]]\n");
1375 PyObject *py_planes;
1377 float eps_coplanar = 1e-4f;
1378 float eps_isect = 1e-6f;
1381 if (!PyArg_ParseTuple(args,
1386 ":points_in_planes",
1395 reinterpret_cast<float **
>(&planes), 4, py_planes,
"points_in_planes")) == -1)
1403 user_data.
py_verts = PyList_New(0);
1404 user_data.
planes_used =
static_cast<char *
>(PyMem_Malloc(
sizeof(
char) * planes_len));
1407 PyObject *py_plane_index = PyList_New(0);
1409 memset(user_data.
planes_used, 0,
sizeof(
char) * planes_len);
1417 for (
int i = 0; i < planes_len; i++) {
1419 PyList_APPEND(py_plane_index, PyLong_FromLong(i));
1426 PyObject *
ret = PyTuple_New(2);
1432#ifndef MATH_STANDALONE
1436 M_Geometry_interpolate_bezier_doc,
1437 ".. function:: interpolate_bezier(knot1, handle1, handle2, knot2, resolution, /)\n"
1439 " Interpolate a bezier spline segment.\n"
1441 " :param knot1: First bezier spline point.\n"
1442 " :type knot1: :class:`mathutils.Vector`\n"
1443 " :param handle1: First bezier spline handle.\n"
1444 " :type handle1: :class:`mathutils.Vector`\n"
1445 " :param handle2: Second bezier spline handle.\n"
1446 " :type handle2: :class:`mathutils.Vector`\n"
1447 " :param knot2: Second bezier spline point.\n"
1448 " :type knot2: :class:`mathutils.Vector`\n"
1449 " :param resolution: Number of points to return.\n"
1450 " :type resolution: int\n"
1451 " :return: The interpolated points.\n"
1452 " :rtype: list[:class:`mathutils.Vector`]\n");
1455 const char *error_prefix =
"interpolate_bezier";
1456 PyObject *py_data[4];
1457 float data[4][4] = {{0.0f}};
1461 float *coord_array, *fp;
1464 if (!PyArg_ParseTuple(args,
1470 ":interpolate_bezier",
1477 for (i = 0; i < 4; i++) {
1484 dims =
max_ii(dims, dims_tmp);
1488 PyErr_SetString(PyExc_ValueError,
"resolution must be 2 or over");
1493 for (i = 0; i < dims; i++) {
1495 UNPACK4_EX(,
data, [i]), coord_array + i, resolu - 1,
sizeof(
float) * dims);
1498 list = PyList_New(resolu);
1500 for (i = 0; i < resolu; i++, fp = fp + dims) {
1503 MEM_delete(coord_array);
1509 M_Geometry_tessellate_polygon_doc,
1510 ".. function:: tessellate_polygon(polylines, /)\n"
1512 " Takes a list of polylines (each point a pair or triplet of numbers) and returns "
1513 "the point indices for a polyline filled with triangles. Does not handle degenerate "
1514 "geometry (such as zero-length lines due to consecutive identical points).\n"
1516 " :param polylines: Polygons where each polygon is a sequence of 2D or 3D points.\n"
1517 " :type polylines: Sequence[Sequence[Sequence[float]]]\n"
1518 " :return: A list of triangles.\n"
1519 " :rtype: list[tuple[int, int, int]]\n");
1524 PyObject *polyLine, *polyVec;
1525 int i, len_polylines, len_polypoints;
1526 bool list_parse_error =
false;
1530 ListBaseT<DispList> dispbase = {
nullptr,
nullptr};
1535 if (!PySequence_Check(polyLineSeq)) {
1536 PyErr_SetString(PyExc_TypeError,
"expected a sequence of poly lines");
1540 len_polylines = PySequence_Size(polyLineSeq);
1542 for (i = 0; i < len_polylines; i++) {
1543 polyLine = PySequence_GetItem(polyLineSeq, i);
1544 if (!PySequence_Check(polyLine)) {
1546 Py_XDECREF(polyLine);
1547 PyErr_SetString(PyExc_TypeError,
1548 "One or more of the polylines is not a sequence of mathutils.Vector's");
1552 len_polypoints = PySequence_Size(polyLine);
1553 if (len_polypoints > 0) {
1556 dl->
nr = len_polypoints;
1564 polyVec = PySequence_GetItem(polyLine,
index);
1566 fp, 2, 3 |
MU_ARRAY_SPILL, polyVec,
"tessellate_polygon: parse coord");
1569 if (polyVec_len == -1) [[unlikely]] {
1570 list_parse_error =
true;
1572 else if (polyVec_len == 2) {
1575 else if (polyVec_len == 3) {
1582 Py_DECREF(polyLine);
1585 if (list_parse_error) {
1591 float down_vec[3] = {0, 0, -1};
1594 is_2d ? down_vec :
nullptr,
1601 dl = dispbase.first();
1603 tri_list = PyList_New(dl->
parts);
1606 PyErr_SetString(PyExc_RuntimeError,
"failed to make a new list");
1610 int *dl_face = dl->
index;
1620 tri_list = PyList_New(0);
1629 PyObject *list_item, *item_1, *item_2;
1633 if (!PyList_Check(value)) {
1634 PyErr_SetString(PyExc_TypeError,
"can only back a list of [x, y, w, h]");
1638 len = PyList_GET_SIZE(value);
1642 for (i = 0; i <
len; i++) {
1643 list_item = PyList_GET_ITEM(value, i);
1644 if (!PyList_Check(list_item) || PyList_GET_SIZE(list_item) < 4) {
1645 MEM_delete(boxarray);
1646 PyErr_SetString(PyExc_TypeError,
"can only pack a list of [x, y, w, h]");
1652 item_1 = PyList_GET_ITEM(list_item, 2);
1653 item_2 = PyList_GET_ITEM(list_item, 3);
1655 box->
w =
float(PyFloat_AsDouble(item_1));
1656 box->
h =
float(PyFloat_AsDouble(item_2));
1660 if (box->
w < 0.0f || box->
h < 0.0f) {
1661 MEM_delete(boxarray);
1662 PyErr_SetString(PyExc_TypeError,
1663 "error parsing width and height values from list: "
1664 "[x, y, w, h], not numbers or below zero");
1671 *r_boxarray = boxarray;
1678 PyObject *list_item;
1680 len = PyList_GET_SIZE(value);
1682 for (i = 0; i <
len; i++) {
1683 const BoxPack *box = &boxarray[i];
1684 list_item = PyList_GET_ITEM(value, box->
index);
1685 PyList_SetItem(list_item, 0, PyFloat_FromDouble(box->
x));
1686 PyList_SetItem(list_item, 1, PyFloat_FromDouble(box->
y));
1692 M_Geometry_box_pack_2d_doc,
1693 ".. function:: box_pack_2d(boxes, /)\n"
1695 " Returns a tuple with the width and height of the packed bounding box.\n"
1697 " :param boxes: list of boxes, each box is a list where the first 4 items are "
1698 "[X, Y, width, height, ...] other items are ignored. "
1699 "The X & Y values in this list are modified to set the packed positions.\n"
1700 " :type boxes: list[list[float]]\n"
1701 " :return: The width and height of the packed bounding box.\n"
1702 " :rtype: tuple[float, float]\n");
1705 float tot_width = 0.0f, tot_height = 0.0f;
1710 if (!PyList_Check(boxlist)) {
1711 PyErr_SetString(PyExc_TypeError,
"expected a list of boxes [[x, y, w, h], ... ]");
1715 len = PyList_GET_SIZE(boxlist);
1722 const bool sort_boxes =
true;
1727 MEM_delete(boxarray);
1730 ret = PyTuple_New(2);
1737 M_Geometry_box_fit_2d_doc,
1738 ".. function:: box_fit_2d(points, /)\n"
1740 " Returns an angle that best fits the points to an axis aligned rectangle\n"
1742 " :param points: Sequence of 2D points.\n"
1743 " :type points: Sequence[Sequence[float]]\n"
1744 " :return: The rotation angle in radians for the best axis-aligned bounding box fit.\n"
1745 " :rtype: float\n");
1754 (
reinterpret_cast<float **
>(&points)), 2, pointlist,
"box_fit_2d");
1766 return PyFloat_FromDouble(
angle);
1771 M_Geometry_convex_hull_2d_doc,
1772 ".. function:: convex_hull_2d(points, /)\n"
1774 " Returns the indices of the points forming the convex hull, in counter-clockwise order.\n"
1776 " :param points: Sequence of 2D points.\n"
1777 " :type points: Sequence[Sequence[float]]\n"
1778 " :return: Indices of convex hull vertices in counter-clockwise order.\n"
1779 " :rtype: list[int]\n");
1788 (
reinterpret_cast<float **
>(&points)), 2, pointlist,
"convex_hull_2d");
1795 Py_ssize_t len_ret, i;
1802 ret = PyList_New(len_ret);
1803 for (i = 0; i < len_ret; i++) {
1804 PyList_SET_ITEM(
ret, i, PyLong_FromLong(index_map[i]));
1807 MEM_delete(index_map);
1812 ret = PyList_New(0);
1824 if (
data.is_empty()) {
1825 return PyList_New(0);
1827 PyObject *
ret = PyList_New(
data.size());
1828 for (
const int i :
data.index_range()) {
1830 PyObject *sublist = PyList_New(group.
size());
1832 PyList_SET_ITEM(sublist, j, PyLong_FromUnsignedLong(group[j]));
1834 PyList_SET_ITEM(
ret, i, sublist);
1841 M_Geometry_delaunay_2d_cdt_doc,
1842 ".. function:: delaunay_2d_cdt(vert_coords, edges, faces, output_type, epsilon, "
1843 "need_ids=True, /)\n"
1845 " Computes the Constrained Delaunay Triangulation of a set of vertices,\n"
1846 " with edges and faces that must appear in the triangulation.\n"
1847 " Some triangles may be eaten away, or combined with other triangles,\n"
1848 " according to output type.\n"
1849 " The returned verts may be in a different order from input verts, may be moved\n"
1850 " slightly, and may be merged with other nearby verts.\n"
1851 " The three returned orig lists give, for each of verts, edges, and faces, the list of\n"
1852 " input element indices corresponding to the positionally same output element.\n"
1853 " For edges, the orig indices start with the input edges and then continue\n"
1854 " with the edges implied by each of the faces (n of them for an n-gon).\n"
1855 " If the need_ids argument is supplied, and False, then the code skips the preparation\n"
1856 " of the orig arrays, which may save some time.\n"
1858 " :param vert_coords: Vertex coordinates (2d)\n"
1859 " :type vert_coords: Sequence[:class:`mathutils.Vector`]\n"
1860 " :param edges: Edges, as pairs of indices in ``vert_coords``\n"
1861 " :type edges: Sequence[tuple[int, int]]\n"
1862 " :param faces: Faces, each sublist is a face, "
1863 "as indices in ``vert_coords`` (CCW oriented).\n"
1864 " :type faces: Sequence[Sequence[int]]\n"
1865 " :param output_type: What output looks like. 0 => triangles with convex hull. "
1866 "1 => triangles inside constraints. "
1867 "2 => the input constraints, intersected. "
1868 "3 => like 2 but detect holes and omit them from output. "
1869 "4 => like 2 but with extra edges to make valid BMesh faces. "
1870 "5 => like 4 but detect holes and omit them from output.\n"
1871 " :type output_type: int\n"
1872 " :param epsilon: For nearness tests; should not be zero\n"
1873 " :type epsilon: float\n"
1874 " :param need_ids: are the orig output arrays needed?\n"
1875 " :type need_ids: bool\n"
1876 " :return: Output tuple, (vert_coords, edges, faces, orig_verts, orig_edges, orig_faces)\n"
1878 "list[:class:`mathutils.Vector`], "
1879 "list[tuple[int, int]], "
1883 "list[list[int]]]\n");
1886 const char *error_prefix =
"delaunay_2d_cdt";
1887 PyObject *vert_coords, *edges, *faces;
1890 bool need_ids =
true;
1891 float (*in_coords)[2] =
nullptr;
1892 int (*in_edges)[2] =
nullptr;
1893 Py_ssize_t vert_coords_len, edges_len;
1894 PyObject *out_vert_coords =
nullptr;
1895 PyObject *out_edges =
nullptr;
1896 PyObject *out_faces =
nullptr;
1897 PyObject *out_orig_verts =
nullptr;
1898 PyObject *out_orig_edges =
nullptr;
1899 PyObject *out_orig_faces =
nullptr;
1900 PyObject *ret_value =
nullptr;
1902 if (!PyArg_ParseTuple(args,
1923 if (in_coords !=
nullptr) {
1924 PyMem_Free(in_coords);
1926 if (in_edges !=
nullptr) {
1927 PyMem_Free(in_edges);
1932 reinterpret_cast<float **
>(&in_coords), 2, vert_coords, error_prefix);
1933 if (vert_coords_len == -1) {
1938 reinterpret_cast<int **
>(&in_edges), 2, edges, error_prefix);
1939 if (edges_len == -1) {
1951 verts[i] = {double(in_coords[i][0]), double(in_coords[i][1])};
1956 in.edge =
Span(
reinterpret_cast<int2 *
>(in_edges), edges_len);
1957 in.face_offsets = face_offsets.
as_span();
1958 in.face_vert_indices = face_vert_indices;
1959 in.epsilon = epsilon;
1965 ret_value = PyTuple_New(6);
1967 out_vert_coords = PyList_New(res.
vert.size());
1968 for (
const int i : res.
vert.index_range()) {
1971 if (item ==
nullptr) {
1972 Py_DECREF(ret_value);
1973 Py_DECREF(out_vert_coords);
1976 PyList_SET_ITEM(out_vert_coords, i, item);
1978 PyTuple_SET_ITEM(ret_value, 0, out_vert_coords);
1980 out_edges = PyList_New(res.
edge.size());
1981 for (
const int i : res.
edge.index_range()) {
1982 PyObject *item = PyTuple_New(2);
1983 PyTuple_SET_ITEM(item, 0, PyLong_FromLong(
long(res.
edge[i][0])));
1984 PyTuple_SET_ITEM(item, 1, PyLong_FromLong(
long(res.
edge[i][1])));
1985 PyList_SET_ITEM(out_edges, i, item);
1987 PyTuple_SET_ITEM(ret_value, 1, out_edges);
1990 PyTuple_SET_ITEM(ret_value, 2, out_faces);
1993 PyTuple_SET_ITEM(ret_value, 3, out_orig_verts);
1996 PyTuple_SET_ITEM(ret_value, 4, out_orig_edges);
1999 PyTuple_SET_ITEM(ret_value, 5, out_orig_faces);
2008# pragma clang diagnostic push
2009# pragma clang diagnostic ignored "-Wcast-function-type"
2011# pragma GCC diagnostic push
2012# pragma GCC diagnostic ignored "-Wcast-function-type"
2017 {
"intersect_ray_tri",
2020 M_Geometry_intersect_ray_tri_doc},
2021 {
"intersect_point_line",
2024 M_Geometry_intersect_point_line_doc},
2025 {
"intersect_point_line_segment",
2028 M_Geometry_intersect_point_line_segment_doc},
2029 {
"intersect_point_tri",
2032 M_Geometry_intersect_point_tri_doc},
2033 {
"closest_point_on_tri",
2036 M_Geometry_closest_point_on_tri_doc},
2037 {
"intersect_point_tri_2d",
2040 M_Geometry_intersect_point_tri_2d_doc},
2041 {
"intersect_point_quad_2d",
2044 M_Geometry_intersect_point_quad_2d_doc},
2045 {
"intersect_line_line",
2048 M_Geometry_intersect_line_line_doc},
2049 {
"intersect_line_line_2d",
2052 M_Geometry_intersect_line_line_2d_doc},
2053 {
"intersect_line_plane",
2056 M_Geometry_intersect_line_plane_doc},
2057 {
"intersect_plane_plane",
2060 M_Geometry_intersect_plane_plane_doc},
2061 {
"intersect_line_sphere",
2064 M_Geometry_intersect_line_sphere_doc},
2065 {
"intersect_line_sphere_2d",
2068 M_Geometry_intersect_line_sphere_2d_doc},
2069 {
"distance_point_to_plane",
2072 M_Geometry_distance_point_to_plane_doc},
2073 {
"intersect_sphere_sphere_2d",
2076 M_Geometry_intersect_sphere_sphere_2d_doc},
2077 {
"intersect_tri_tri_2d",
2080 M_Geometry_intersect_tri_tri_2d_doc},
2084 M_Geometry_area_tri_doc},
2085 {
"volume_tetrahedron",
2088 M_Geometry_volume_tetrahedron_doc},
2089 {
"normal",
static_cast<PyCFunction
>(
M_Geometry_normal), METH_VARARGS, M_Geometry_normal_doc},
2090 {
"barycentric_transform",
2093 M_Geometry_barycentric_transform_doc},
2094 {
"points_in_planes",
2097 M_Geometry_points_in_planes_doc},
2098#ifndef MATH_STANDALONE
2099 {
"interpolate_bezier",
2102 M_Geometry_interpolate_bezier_doc},
2103 {
"tessellate_polygon",
2106 M_Geometry_tessellate_polygon_doc},
2110 M_Geometry_convex_hull_2d_doc},
2114 M_Geometry_delaunay_2d_cdt_doc},
2118 M_Geometry_box_fit_2d_doc},
2122 M_Geometry_box_pack_2d_doc},
2124 {
nullptr,
nullptr, 0,
nullptr},
2129# pragma clang diagnostic pop
2131# pragma GCC diagnostic pop
2138 "The Blender geometry module.");
2141 "mathutils.geometry",
display list (or rather multi purpose list) stuff.
#define BLI_SCOPED_DEFER(function_to_defer)
Read Blender memory allocation and freeing.
#define UNPACK3_EX(pre, a, post)
#define UNPACK4_EX(pre, a, post)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Span< T > as_span() const
IndexRange index_range() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
Array< Vector< int > > face
Array< Vector< uint32_t > > vert_orig
Array< Vector< uint32_t > > face_orig
Array< VecBase< T, 2 > > vert
Array< Vector< uint32_t > > edge_orig
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
CDT_result< T > delaunay_2d_calc(const CDT_input< T > &input, CDT_output_type output_type)
static PyObject * M_Geometry_area_tri(PyObject *, PyObject *args)
bool isect_point_tri_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3], float r_isect_co[3])
static PyObject * M_Geometry_delaunay_2d_cdt(PyObject *, PyObject *args)
bool isect_plane_plane_v3(const float plane_a[4], const float plane_b[4], float r_isect_co[3], float r_isect_no[3]) ATTR_WARN_UNUSED_RESULT
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
static PyObject * M_Geometry_interpolate_bezier(PyObject *, PyObject *args)
int isect_line_sphere_v3(const float l1[3], const float l2[3], const float sp[3], float r, float r_p1[3], float r_p2[3])
static PyModuleDef M_Geometry_module_def
int PyC_ParseBool(PyObject *o, void *p)
static PyObject * M_Geometry_intersect_point_tri(PyObject *, PyObject *args)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bool mathutils_array_parse_alloc_viseq(PyObject *value, const char *error_prefix, Array< int > &r_offsets, Array< int > &r_data)
void BKE_displist_fill(const ListBaseT< DispList > *dispbase, ListBaseT< DispList > *to, const float normal_proj[3], bool flip_normal, CurveFillSolverType fill_solver, CurveFillRuleType fill_rule)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void BKE_displist_free(ListBaseT< DispList > *lb)
int isect_line_sphere_v2(const float l1[2], const float l2[2], const float sp[2], float r, float r_p1[2], float r_p2[2])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
static PyObject * M_Geometry_closest_point_on_tri(PyObject *, PyObject *args)
float normal_poly_v3(float n[3], const float verts[][3], unsigned int nr)
static PyObject * M_Geometry_intersect_point_quad_2d(PyObject *, PyObject *args)
static PyObject * M_Geometry_intersect_point_line(PyObject *, PyObject *const *args, Py_ssize_t nargs)
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
void transform_point_by_tri_v3(float pt_tar[3], float const pt_src[3], const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3])
float closest_to_line_segment_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE int max_ii(int a, int b)
ATTR_WARN_UNUSED_RESULT const BMVert * v
static int boxPack_FromPyObject(PyObject *value, BoxPack **r_boxarray)
int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
static PyObject * M_Geometry_tessellate_polygon(PyObject *, PyObject *polyLineSeq)
bool isect_planes_v3_fn(const float planes[][4], int planes_len, float eps_coplanar, float eps_isect, void(*callback_fn)(const float co[3], int i, int j, int k, void *user_data), void *user_data)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
int mathutils_array_parse_alloc_vi(int **array, int array_dim, PyObject *value, const char *error_prefix)
static PyObject * M_Geometry_intersect_line_sphere(PyObject *, PyObject *args)
MINLINE void mul_v3_fl(float r[3], float f)
static PyObject * M_Geometry_intersect_line_sphere_2d(PyObject *, PyObject *args)
int BLI_convexhull_2d(Span< float2 > points, int r_points[])
static PyObject * M_Geometry_normal(PyObject *, PyObject *args)
PyObject * PyC_Tuple_Pack_I32(const Span< int > values)
static void boxPack_ToPyObject(PyObject *value, const BoxPack *boxarray)
float volume_tetrahedron_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
static PyMethodDef M_Geometry_methods[]
PyObject * Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObject *base_type)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
static PyObject * M_Geometry_barycentric_transform(PyObject *, PyObject *args)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
static PyObject * M_Geometry_intersect_ray_tri(PyObject *, PyObject *args)
MINLINE float area_tri_v2(const float v1[2], const float v2[2], const float v3[2])
@ CU_FILL_SOLVER_SWEEP_LINE
BMesh const char void * data
float line_point_factor_v2(const float p[2], const float l1[2], const float l2[2])
static PyObject * M_Geometry_points_in_planes(PyObject *, PyObject *args)
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
static PyObject * M_Geometry_box_fit_2d(PyObject *, PyObject *pointlist)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
static PyObject * M_Geometry_intersect_line_line(PyObject *, PyObject *args)
int isect_point_quad_v2(const float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2])
static PyObject * M_Geometry_intersect_tri_tri_2d(PyObject *, PyObject *args)
static void points_in_planes_fn(const float co[3], int i, int j, int k, void *user_data_p)
static PyObject * M_Geometry_intersect_point_line_segment(PyObject *, PyObject *const *args, Py_ssize_t nargs)
bool isect_line_plane_v3(float r_isect_co[3], const float l1[3], const float l2[3], const float plane_co[3], const float plane_no[3]) ATTR_WARN_UNUSED_RESULT
float BLI_convexhull_aabb_fit_points_2d(Span< float2 > points)
static PyObject * M_Geometry_intersect_line_plane(PyObject *, PyObject *args)
static PyObject * M_Geometry_intersect_sphere_sphere_2d(PyObject *, PyObject *args)
MINLINE float normalize_v3(float n[3])
static PyObject * M_Geometry_box_pack_2d(PyObject *, PyObject *boxlist)
static PyObject * M_Geometry_distance_point_to_plane(PyObject *, PyObject *args)
static PyObject * list_of_lists_from_arrays(const Span< Vector< T > > data)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
float area_tri_v3(const float v1[3], const float v2[3], const float v3[3])
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
void closest_on_tri_to_point_v3(float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
bool isect_tri_tri_v2(const float t_a0[2], const float t_a1[2], const float t_a2[2], const float t_b0[2], const float t_b1[2], const float t_b2[2])
static PyObject * M_Geometry_intersect_plane_plane(PyObject *, PyObject *args)
static PyObject * M_Geometry_volume_tetrahedron(PyObject *, PyObject *args)
PyMODINIT_FUNC PyInit_mathutils_geometry()
static PyObject * M_Geometry_intersect_line_line_2d(PyObject *, PyObject *args)
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
static PyObject * M_Geometry_convex_hull_2d(PyObject *, PyObject *pointlist)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BLI_box_pack_2d(BoxPack *boxarray, unsigned int len, bool sort_boxes, float *r_tot_x, float *r_tot_y)
int mathutils_array_parse_alloc_v(float **array, int array_dim, PyObject *value, const char *error_prefix)
static PyObject * M_Geometry_intersect_point_tri_2d(PyObject *, PyObject *args)
int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float r_i1[3], float r_i2[3])
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
int _PyArg_CheckPositional(const char *name, Py_ssize_t nargs, Py_ssize_t min, Py_ssize_t max)
header-only compatibility defines.
#define PyTuple_SET_ITEMS(op_arg,...)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float