From 25b61d8deda76e543e6b1fe99d57a3da7722d89f Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Tue, 5 Apr 2022 11:37:43 +0800 Subject: [PATCH] return [] if no intersection --- src/experimental/convex_intersection.scad | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/experimental/convex_intersection.scad b/src/experimental/convex_intersection.scad index bd8462dc..81d26383 100644 --- a/src/experimental/convex_intersection.scad +++ b/src/experimental/convex_intersection.scad @@ -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],