2019-09-27 11:13:54 +08:00
|
|
|
include <hull_polyline3d.scad>;
|
|
|
|
|
2019-09-28 09:58:30 +08:00
|
|
|
side_leng = 100;
|
2019-09-28 17:29:51 +08:00
|
|
|
min_leng = 5;
|
2019-09-27 11:13:54 +08:00
|
|
|
thickness = 2.5;
|
|
|
|
|
2019-09-28 17:29:51 +08:00
|
|
|
sierpinski_pyramid(side_leng, min_leng, thickness, $fn = 4);
|
2019-09-27 11:13:54 +08:00
|
|
|
|
2019-09-28 17:29:51 +08:00
|
|
|
module sierpinski_pyramid(side_leng, min_leng, thickness) {
|
2019-09-28 09:58:30 +08:00
|
|
|
pyramid_frame(side_leng, thickness);
|
2019-09-28 17:29:51 +08:00
|
|
|
if(side_leng > min_leng){
|
2019-09-28 09:58:30 +08:00
|
|
|
half_len = side_leng / 2;
|
|
|
|
h = half_len * 0.707107;
|
|
|
|
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)
|
2019-09-28 17:29:51 +08:00
|
|
|
sierpinski_pyramid(half_len, min_leng, thickness);
|
2019-09-27 11:13:54 +08:00
|
|
|
}
|
|
|
|
translate([0, 0, h])
|
2019-09-28 17:29:51 +08:00
|
|
|
sierpinski_pyramid(half_len, min_leng, thickness);
|
2019-09-27 11:13:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-28 09:58:30 +08:00
|
|
|
module pyramid_frame(side_leng, thickness) {
|
|
|
|
half_len = side_leng / 2;
|
|
|
|
h = half_len * 1.414214;
|
2019-09-27 11:13:54 +08:00
|
|
|
|
2019-09-28 09:58:30 +08:00
|
|
|
tri_pts = [[0, 0, h], [half_len, half_len, 0], [half_len, -half_len, 0], [0, 0, h]];
|
|
|
|
line_pts = [[half_len, half_len, 0], [-half_len, half_len, 0]];
|
2019-09-27 11:13:54 +08:00
|
|
|
|
2019-09-28 09:58:30 +08:00
|
|
|
hull_polyline3d(tri_pts, thickness);
|
2019-09-27 11:13:54 +08:00
|
|
|
mirror([1, 0, 0])
|
2019-09-28 09:58:30 +08:00
|
|
|
hull_polyline3d(tri_pts, thickness);
|
2019-09-27 11:13:54 +08:00
|
|
|
|
2019-09-28 09:58:30 +08:00
|
|
|
hull_polyline3d(line_pts, thickness);
|
2019-09-27 11:13:54 +08:00
|
|
|
mirror([0, 1, 0])
|
2019-09-28 09:58:30 +08:00
|
|
|
hull_polyline3d(line_pts, thickness);
|
2019-09-27 11:13:54 +08:00
|
|
|
}
|