2022-06-06 13:11:46 +08:00
|
|
|
use <util/rand.scad>
|
|
|
|
use <experimental/circle_packing.scad>
|
2019-08-18 10:03:38 +08:00
|
|
|
|
2022-05-31 14:36:23 +08:00
|
|
|
size = [200, 100];
|
|
|
|
min_radius = 1;
|
|
|
|
point_numbers = 100;
|
2019-08-18 10:03:38 +08:00
|
|
|
|
2022-05-31 14:36:23 +08:00
|
|
|
points = [
|
|
|
|
for(i = [0:point_numbers - 1])
|
|
|
|
[rand(0, size.x), rand(0, size.y)]
|
|
|
|
];
|
2019-08-18 10:03:38 +08:00
|
|
|
|
2022-06-03 10:37:45 +08:00
|
|
|
circles = circle_packing(points, min_radius);
|
2022-05-31 14:36:23 +08:00
|
|
|
mr = max([for(c = circles) c[1]]);
|
2019-09-26 08:53:47 +08:00
|
|
|
translate([0, 0, mr])
|
|
|
|
for(c = circles) {
|
2022-05-31 14:36:23 +08:00
|
|
|
translate(c[0])
|
|
|
|
sphere(c[1], $fn = 48);
|
2019-09-26 08:53:47 +08:00
|
|
|
}
|
|
|
|
|
2019-08-18 10:03:38 +08:00
|
|
|
for(c = circles) {
|
2022-05-31 14:36:23 +08:00
|
|
|
translate(c[0])
|
2019-09-26 08:53:47 +08:00
|
|
|
linear_extrude(mr)
|
2022-05-31 14:36:23 +08:00
|
|
|
circle(c[1]/ 3, $fn = 48);
|
2019-08-18 10:03:38 +08:00
|
|
|
}
|
|
|
|
linear_extrude(1) square(size);
|