mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-01 04:20:27 +02:00
Merge branch 'master' of https://github.com/JustinSDK/dotSCAD
This commit is contained in:
@@ -1,11 +1,28 @@
|
||||
use <experimental/_impl/_convex_hull_impl.scad>;
|
||||
use <hull_polyline2d.scad>;
|
||||
use <experimental/voronoi_lines.scad>;
|
||||
use <experimental/convex_hull.scad>;
|
||||
|
||||
function convex_hull(points) =
|
||||
let(
|
||||
sorted = _convex_hull_sort_by_xy(points),
|
||||
leng = len(sorted),
|
||||
lwr_ch = _convex_hull_lower_chain(sorted, leng, [], 0, 0),
|
||||
leng_lwr_ch = len(lwr_ch),
|
||||
chain = _convex_hull_upper_chain(sorted, lwr_ch, leng_lwr_ch, leng_lwr_ch + 1, leng - 2)
|
||||
)
|
||||
[for(i = [0:len(chain) - 2]) chain[i]];
|
||||
pt_nums = 50;
|
||||
width = 1;
|
||||
points = [for(i = [0:pt_nums - 1]) rands(-50, 50, 2)];
|
||||
|
||||
intersection() {
|
||||
for(line = voronoi_lines(points)) {
|
||||
hull_polyline2d(
|
||||
line,
|
||||
width = width,
|
||||
$fn = 4
|
||||
);
|
||||
}
|
||||
hull()
|
||||
#for(p = points) {
|
||||
translate(p)
|
||||
circle(.5);
|
||||
}
|
||||
}
|
||||
|
||||
hull_pts = convex_hull(points);
|
||||
hull_polyline2d(
|
||||
concat(hull_pts, [hull_pts[0]]),
|
||||
width = width, $fn = 4
|
||||
);
|
Reference in New Issue
Block a user