-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSierpinski.scad
39 lines (31 loc) · 895 Bytes
/
Sierpinski.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Sierpinski Cube
// by Gregory Propf, Copyright 2015
xlist = [0,1,2,0,2,0,1,2,0,2,0,2,0,1,2,0,2,0,1,2];
ylist = [0,0,0,1,1,2,2,2,0,0,2,2,0,0,0,1,1,2,2,2];
zlist = [0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2];
// "Club" pattern
//xlist = [0,1,2,1,1,1,1];
//ylist = [1,1,1,0,2,1,1];
//zlist = [1,1,1,1,1,0,2];
//xlist = [0,1,2,0,1,2,0,2,0,0,0,0,0,0,0,0];
//ylist = [0,0,0,0,0,0,0,0,1,2,0,1,2,0,2,0];
//zlist = [0,0,0,2,2,2,1,1,0,0,0,2,2,2,1,1];
scube(25,4);
slop = 0.001;
module placeCube(x,y,z,length,depth) {
translate([length*x,length*y,length*z])
scube(length,depth);
//echo ("x:",length*x);
}
module scube(length,depth) {
scubeLength = length / 3;
if (depth == 1) {
cube(length+slop,$fn=1);
}
else {
for (i = [0:len(xlist)-1]) {
//echo (xlist[i]);
placeCube(xlist[i],ylist[i],zlist[i],scubeLength,depth - 1);
}
}
}