1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-16 21:58:26 +01:00
dotSCAD/examples/circle_packing/packing_circles.scad
2022-06-06 13:11:46 +08:00

27 lines
538 B
OpenSCAD

use <util/rand.scad>
use <experimental/circle_packing.scad>
size = [200, 100];
min_radius = 1;
point_numbers = 100;
points = [
for(i = [0:point_numbers - 1])
[rand(0, size.x), rand(0, size.y)]
];
circles = circle_packing(points, min_radius);
mr = max([for(c = circles) c[1]]);
translate([0, 0, mr])
for(c = circles) {
translate(c[0])
sphere(c[1], $fn = 48);
}
for(c = circles) {
translate(c[0])
linear_extrude(mr)
circle(c[1]/ 3, $fn = 48);
}
linear_extrude(1) square(size);