Last active
April 14, 2020 04:03
-
-
Save creationix/b2d8c08ad3fa3c4502571624135b27e1 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
// For golden ratio rectangles | |
phi = (1 + sqrt(5)) / 2; | |
echo("phi",phi); | |
// dihedral angle of icosahedron | |
dih = acos(sqrt(5) / -3); | |
echo("dih",dih); | |
model="low_poly_person_by_Rochus.stl"; | |
modelHeight=14.274; | |
// 2x6 boards 8 feeth long. | |
l=8*12; | |
w=1.5; | |
h=5.5; | |
points = [ | |
[phi*l/2,l/2,0],[0,phi*l/2,l/2],[l/2,0,phi*l/2], | |
[-l/2,0,phi*l/2],[-phi*l/2,l/2,0],[-phi*l/2,-l/2,0], | |
[0,-phi*l/2,l/2],[phi*l/2,-l/2,0],[l/2,0,-phi*l/2], | |
[0,phi*l/2,-l/2],[-l/2,0,-phi*l/2] | |
]; | |
faces = [ | |
[1,0,2], // t | |
[1,2,3], // t | |
[1,3,4], // t | |
[1,9,0], // t | |
[1,4,9], // t | |
[8,0,9], // l | |
[10,9,4], // l | |
[5,4,3], // l | |
[6,3,2], // l | |
[7,2,0], // l | |
[2,7,6], // d | |
[3,6,5], // d | |
[0,8,7], // d | |
[9,10,8], // d | |
[4,5,10], // d | |
]; | |
// normalize a vector to length 1 | |
function normalize(a) = [ | |
a[0] / sqrt(a * a), | |
a[1] / sqrt(a * a), | |
a[2] / sqrt(a * a) | |
]; | |
translate([0,0,40.8]){ | |
rotate([180/PI+1,0,0]){ | |
wa = w / sin(60); | |
ha = h / sin(60); | |
for (idx = [ 0 : len(faces) - 1 ] ) { | |
a=points[faces[idx][0]]; | |
b=points[faces[idx][1]]; | |
c=points[faces[idx][2]]; | |
as=a+normalize(c-a)*wa; | |
am=as+normalize(b-a)*wa; | |
bs=b+normalize(a-b)*wa; | |
bm=bs+normalize(c-b)*wa; | |
cs=c+normalize(b-c)*wa; | |
cm=cs+normalize(a-c)*wa; | |
a2=a-normalize(a)*ha; | |
as2=as-normalize(a)*ha; | |
am2=am-normalize(a)*ha; | |
b2=b-normalize(b)*ha; | |
bs2=bs-normalize(b)*ha; | |
bm2=bm-normalize(b)*ha; | |
c2=c-normalize(c)*ha; | |
cs2=cs-normalize(c)*ha; | |
cm2=cm-normalize(c)*ha; | |
color("#ccbb77") | |
polyhedron([ | |
a,as,am, | |
b,bs,bm, | |
c,cs,cm, | |
a2,as2,am2, | |
b2,bs2,bm2, | |
c2,cs2,cm2, | |
],[ | |
// tops | |
[0,4,5,1], | |
[3,7,8,4], | |
[6,1,2,7], | |
// bottoms | |
[9,10,14,13], | |
[12,13,17,16], | |
[15,16,11,10], | |
// outsides | |
[4,0,9,13], | |
[7,3,12,16], | |
[1,6,15,10], | |
// insides | |
[2,5,14,11], | |
[5,8,17,14], | |
[8,2,11,17], | |
// exposed ends | |
[0,1,10,9], | |
[6,7,16,15], | |
[3,4,13,12], | |
// hidden ends | |
[5,4,13,14], | |
[8,7,16,17], | |
[2,1,10,11], | |
]); | |
up = normalize((b + c) / 2 - a); | |
right = normalize(c - b); | |
out = normalize((a+b+c)/3); | |
outl = normalize((a+b)/2); | |
outr = normalize((a+c)/2); | |
color("#ddddaa") | |
if (idx < 10) for (j = [ha:ha*2:l-ha]) { | |
p1 = a+normalize(b-a)*j; | |
p2 = a+normalize(b-a)*(j+ha); | |
p3 = a+normalize(c-a)*j; | |
p4 = a+normalize(c-a)*(j+ha); | |
polyhedron([ | |
p1,p2,p3,p4, | |
p1 + outl * wa, | |
p2 + outl * wa, | |
p3 + outr * wa, | |
p4 + outr * wa, | |
], | |
[ | |
[4,5,7,6], // outside | |
[0,2,3,1], // inside | |
[5,1,3,7], // top | |
[6,2,0,4], // bottom | |
[4,0,1,5], // left | |
[7,3,2,6], // right | |
]); | |
} | |
// Solar panel | |
if (idx < 2) { | |
bl = a + up * 46 + out * w - right * 39.5/2; | |
br = bl + right * 39.5; | |
ul = bl + up * 39; | |
ur = br + up * 39; | |
points = [ | |
bl + out * 1.5, // 0 | |
br + out * 1.5, // 1 | |
ul + out * 1.5, // 2 | |
ur + out * 1.5, // 3 | |
bl, // 4 | |
br, // 5 | |
ul, // 6 | |
ur, // 7 | |
]; | |
// mono crystals | |
color("#333333") polyhedron(points, [ | |
[0,2,3,1], | |
]); | |
// frame | |
color("#ddd") polyhedron(points, [ | |
[0,4,6,2], // left | |
[2,6,7,3], // top | |
[3,7,5,1], // right | |
[1,5,4,0], // bottom | |
]); | |
} | |
} | |
//color("orange",0.5){ | |
// cube([phi*l,l,0.5], true); | |
// cube([0.5,phi*l,l], true); | |
// cube([l,0.5,phi*l], true); | |
//} | |
//#polyhedron(points, faces); | |
} | |
} | |
family = [ | |
[76,-20,32,10], | |
[67,20,30,-14], | |
[63,30,-40,30], | |
[57.5,-50,-15,-90], | |
[47.5,45,10,105], | |
[45,-30,-30,60], | |
[39,10,0,-60], | |
]; | |
color("#55aaff",0.4) | |
for (idx = [ 0 : len(family) - 1 ] ) { | |
person = family[idx]; | |
s = person[0]/modelHeight; | |
translate([person[1],person[2],0]) | |
rotate([0,0,person[3]]) scale([s,s,s]) import(model); | |
} |
Author
creationix
commented
Apr 13, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment