mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-02-24 17:42:44 +01:00
add convex_intersection
This commit is contained in:
parent
d2e2c7867a
commit
f206de4a1a
12
src/experimental/_impl/_convex_intersection_impl.scad
Normal file
12
src/experimental/_impl/_convex_intersection_impl.scad
Normal 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
|
||||||
|
];
|
17
src/experimental/convex_intersection.scad
Normal file
17
src/experimental/convex_intersection.scad
Normal 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)]
|
||||||
|
)
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user