1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-06 23:06:43 +02:00

return [] if no intersection

This commit is contained in:
Justin Lin
2022-04-05 11:37:43 +08:00
parent 6d4f7661ec
commit 25b61d8ded

View File

@@ -7,9 +7,14 @@ function convex_intersection(shape1, shape2, epsilon = 0.0001) =
(shape1 == [] || shape2 == []) ? [] :
let(
leng = len(shape1),
pts = [each shape1, shape1[0]]
pts = [each shape1, shape1[0]],
convex = concat(
[for(p = shape1) if(in_shape(shape2, p, include_edge = true)) p],
[for(p = shape2) if(in_shape(shape1, p, include_edge = true)) p],
[for(i = [0:leng - 1]) each _intersection_ps(shape2, [pts[i], pts[i + 1]], epsilon)]
)
)
convex_ct_clk_order(
convex == [] ? [] : convex_ct_clk_order(
concat(
[for(p = shape1) if(in_shape(shape2, p, include_edge = true)) p],
[for(p = shape2) if(in_shape(shape1, p, include_edge = true)) p],