2022-06-06 13:11:46 +08:00
|
|
|
use <polyline_join.scad>
|
2019-09-27 11:13:54 +08:00
|
|
|
|
2019-09-28 09:58:30 +08:00
|
|
|
side_leng = 100;
|
2019-09-28 17:29:51 +08:00
|
|
|
min_leng = 5;
|
2021-02-18 10:45:44 +08:00
|
|
|
diameter = 2.5;
|
2019-09-27 11:13:54 +08:00
|
|
|
|
2021-02-18 10:45:44 +08:00
|
|
|
sierpinski_pyramid(side_leng, min_leng, diameter, $fn = 4);
|
2019-09-27 11:13:54 +08:00
|
|
|
|
2021-02-18 10:45:44 +08:00
|
|
|
module sierpinski_pyramid(side_leng, min_leng, diameter) {
|
|
|
|
pyramid_frame(side_leng, diameter);
|
2019-09-28 17:29:51 +08:00
|
|
|
if(side_leng > min_leng){
|
2019-09-28 17:33:04 +08:00
|
|
|
half_leng = side_leng / 2;
|
|
|
|
h = half_leng * 0.707107;
|
2019-09-28 09:58:30 +08:00
|
|
|
pt = [side_leng / 4, side_leng / 4, 0];
|
2019-09-27 11:13:54 +08:00
|
|
|
for(i=[0:3]) {
|
|
|
|
rotate([0, 0, i * 90])
|
|
|
|
translate(pt)
|
2021-02-18 10:45:44 +08:00
|
|
|
sierpinski_pyramid(half_leng, min_leng, diameter);
|
2019-09-27 11:13:54 +08:00
|
|
|
}
|
|
|
|
translate([0, 0, h])
|
2021-02-18 10:45:44 +08:00
|
|
|
sierpinski_pyramid(half_leng, min_leng, diameter);
|
2019-09-27 11:13:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-18 10:45:44 +08:00
|
|
|
module pyramid_frame(side_leng, diameter) {
|
2019-09-28 17:33:04 +08:00
|
|
|
half_leng = side_leng / 2;
|
|
|
|
h = half_leng * 1.414214;
|
2019-09-27 11:13:54 +08:00
|
|
|
|
2019-09-28 17:33:04 +08:00
|
|
|
tri_pts = [[0, 0, h], [half_leng, half_leng, 0], [half_leng, -half_leng, 0], [0, 0, h]];
|
|
|
|
line_pts = [[half_leng, half_leng, 0], [-half_leng, half_leng, 0]];
|
2019-09-27 11:13:54 +08:00
|
|
|
|
2021-10-08 09:36:01 +08:00
|
|
|
polyline_join(tri_pts)
|
|
|
|
sphere(d = diameter);
|
2019-09-27 11:13:54 +08:00
|
|
|
mirror([1, 0, 0])
|
2021-10-08 09:36:01 +08:00
|
|
|
polyline_join(tri_pts)
|
|
|
|
sphere(d = diameter);
|
2019-09-27 11:13:54 +08:00
|
|
|
|
2021-10-08 09:36:01 +08:00
|
|
|
polyline_join(line_pts)
|
|
|
|
sphere(d = diameter);
|
2019-09-27 11:13:54 +08:00
|
|
|
mirror([0, 1, 0])
|
2021-10-08 09:36:01 +08:00
|
|
|
polyline_join(line_pts)
|
|
|
|
sphere(d = diameter);
|
2019-09-27 11:13:54 +08:00
|
|
|
}
|