1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-24 09:33:26 +01:00

add convex_intersection

This commit is contained in:
Justin Lin 2020-02-22 09:59:31 +08:00
parent d2e2c7867a
commit f206de4a1a
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,12 @@
use <experimental/intersection_p.scad>;
function _intersection_ps(shape, line_pts, epsilon) =
let(
leng = len(shape),
pts = concat(shape, [shape[0]])
)
[
for(i = [0:leng - 1])
let(p = intersection_p(line_pts, [pts[i], pts[i + 1]], epsilon = epsilon))
if(p != []) p
];

View File

@ -0,0 +1,17 @@
use <in_shape.scad>;
use <experimental/_impl/_convex_intersection_impl.scad>;
use <experimental/convex_ct_clk_order.scad>;
function convex_intersection(shape1, shape2, epsilon = 0.0001) =
let(
leng = len(shape1),
pts = concat(shape1, [shape1[0]])
)
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],
[for(i = [0:leng - 1]) each _intersection_ps(shape2, [pts[i], pts[i + 1]], epsilon)]
)
);