Created
January 5, 2022 00:39
-
-
Save creationix/7a56e6e2395564752fd87a42189daebf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count=9; | |
h=100; | |
r=27; | |
s=4; | |
g=1.1; | |
w=(r+s)*(count+1)+s*2; | |
echo(w); | |
d=(r+s)*(2+2*sin(60))+s*2; | |
x1=(1-sin(60))*(2*s + r); | |
y1=(1+cos(60))*(2*s + r); | |
x2=x1; | |
y2=(1-cos(60))*(2*s + r); | |
d1=y1 - x1 * (sin(60)/cos(60)); | |
d3=y2 + x1 * (sin(60)/cos(60)); | |
w1=x1 + (d-y1) * (cos(60)/sin(60)); | |
w3=x2 + y2 * (cos(60)/sin(60)); | |
w2=w-w1; | |
w4=w-w3; | |
d2=d-d1; | |
d4=d-d3; | |
difference() { | |
linear_extrude(height=h) | |
if (count%2==1) { | |
polygon([ | |
[w3,0], | |
//[x2,y2], | |
[0,d3], | |
[0,d1], | |
//[x1,y1], | |
[w1,d], | |
[w2,d], | |
[w,d1], | |
[w,d3], | |
[w4,0], | |
]); | |
} else { | |
polygon([ | |
[w3,0], | |
//[x2,y2], | |
[0,d3], | |
[0,d1], | |
//[x1,y1], | |
[w1,d], | |
[w4,d], | |
[w,d4], | |
[w,d2], | |
[w2,0], | |
]); | |
} | |
translate([r+s*2,r+s*2,h/2+s*2]){ | |
for(i=[0:count-1]) { | |
translate([(r+s)*i,0,0]) { | |
if (i%2==0) { | |
cylinder(h=h,r=r,center=true); | |
translate([0,-r,-h/8]) { | |
cube([r*g,r*2,h*1.5],center=true); | |
translate([0,r]) | |
cylinder(h=h*1.5,r=r*g*.5,center=true); | |
} | |
} else { | |
translate([0,(r+s)*2*sin(60),0]) { | |
cylinder(h=h,r=r,center=true); | |
translate([0,r,-h/8]) | |
cube([r*g,r*2,h*1.5],center=true); | |
cylinder(h=h*1.5,r=r*g*.5,center=true); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment