開始是想做個3維的Vicsek fractal 打印出來。2維的Vicsek fractal是這個樣子:
但是吧,這個形狀包含連續的對角線,所以修改了一下,改成在正方形的中間挖一個1/3的正方形,然後在4個角重複這個操作。
於是就這樣了:
WD=81;
DP =3;
function getL(w,x,y,d)=
d<=1?
[[w,x,y]]
:
concat( [[w,x,y]]
,getL(w/3,x+w,y+w,d-1)
,getL(w/3,x-w,y+w,d-1)
,getL(w/3,x+w,y-w,d-1)
,getL(w/3,x-w,y-w,d-1)
)
;
module cL(widths=81,deeps=1){
color("red")
for (a = getL(widths/3,0,0,deeps))
translate([a[1],a[2], 0])
cube([a[0],a[0],widths], center = true);
}
difference() {
color("green") cube(WD,center = true);
union(){
rotate(a=[ 0,90, 0])cL(WD,DP);
rotate(a=[90, 0, 0])cL(WD,DP);
rotate(a=[ 0, 0,90])cL(WD,DP);
}
}