Skip to content

Instantly share code, notes, and snippets.

@rafacouto
Last active February 7, 2017 12:55
Show Gist options
  • Save rafacouto/67af4c1116e3882cb48e32259fb58230 to your computer and use it in GitHub Desktop.
Save rafacouto/67af4c1116e3882cb48e32259fb58230 to your computer and use it in GitHub Desktop.
// parameters
edge_mm = 30;
thickness = 0.95;
// constants
phi = (1 + sqrt(5)) / 2;
phi2 = phi * phi;
phi3 = phi2 * phi;
module piece_s3(points) {
faces = [
[ 0, 1, 2 ], // top
[ 5, 4, 3 ], // bottom
[ 2, 1, 4, 5 ], // front
[ 1, 0, 3, 4 ], // back
[ 0, 2, 5, 3 ], // left
];
color("blue") polyhedron(concat(points, points*thickness), faces);
};
difference () {
scale(edge_mm / 2)
translate([1/sqrt(3), 0, 0])
rotate([0,180-atan((phi3 - 2 - phi) / (phi2 - 1)),0])
translate([-1,0, -phi3])
piece_s3([
[ 1, 1, phi3 ], [ phi2, 0, 2+phi ], [ 1, -1, phi3 ]
]);
translate([0, 0, -50]) linear_extrude(100)
polygon([[3.0, 5.2], [3.0, -3.6], [1.4, -5.2], [-1.4, -5.2], [-3.0, -3.6], [-3.0, 5.2]]);
}
// parameters
edge_mm = 30;
thickness = 0.95;
// constants
phi = (1 + sqrt(5)) / 2;
phi2 = phi * phi;
phi3 = phi2 * phi;
module piece_s4(points) {
faces = [
[ 0, 1, 2, 3 ], // top
[ 7, 6, 5, 4 ], // bottom
[ 2, 1, 5, 6 ], // front
[ 1, 0, 4, 5 ], // right
[ 0, 3, 7, 4 ], // back
[ 3, 2, 6, 7 ], // left
];
color("yellow") polyhedron(concat(points, points*thickness), faces);
};
difference () {
scale(edge_mm / 2) rotate([180, 0, 0]) translate([0,0,-phi3]) piece_s4(
[[ 1, 1, phi3 ], [ 1, -1, phi3 ], [ -1, -1, phi3 ], [ -1, 1, phi3 ]]);
translate([0, 0, -50]) linear_extrude(100)
polygon([[3.0, 5.2], [3.0, -3.6], [1.4, -5.2], [-1.4, -5.2], [-3.0, -3.6], [-3.0, 5.2]]);
}
// parameters
edge_mm = 30;
thickness = 0.95;
// constants
phi = (1 + sqrt(5)) / 2;
phi2 = phi * phi;
phi3 = phi2 * phi;
module piece_s5(points) {
faces = [
[ 0, 1, 2, 3, 4 ], // top
[ 9, 8, 7, 6, 5 ], // bottom
[ 1, 0, 5, 6 ], // first
[ 2, 1, 6, 7 ], // second
[ 3, 2, 7, 8 ], // third
[ 4, 3, 8, 9 ], // fourth
[ 0, 4, 9, 5 ] // fifth
];
color("red") polyhedron(concat(points, points*thickness), faces);
};
difference () {
scale(edge_mm / 2)
translate([0, -phi2/2, 0])
rotate([180 - atan((phi3 - 2*phi) / (phi2 - 1)), 0, 0])
translate([0, 1, -phi3])
piece_s5([
[ 1, -1, phi3 ],
[ phi, -phi2, 2*phi ],
[ 0, -2-phi, phi2 ],
[ -phi, -phi2, 2*phi ],
[ -1, -1, phi3 ],
]);
translate([0, 0, -50]) linear_extrude(100)
polygon([[3.0, 5.2], [3.0, -3.6], [1.4, -5.2], [-1.4, -5.2], [-3.0, -3.6], [-3.0, 5.2]]);
}
// parameters
edge = 10; // 10mm
thickness = 0.9; // -10%
// constants
phi = (1 + sqrt(5)) / 2;
phi2 = phi * phi;
phi3 = phi2 * phi;
// 0 < 1 < phi < phi2 < 2*phi < 2+phi < phi3
function interior_s3(points) = [ points[0] * thickness, points[1] * thickness, points[2] * thickness ];
function interior_s4(points) = [ points[0] * thickness, points[1] * thickness, points[2] * thickness, points[3] * thickness ];
function interior_s5(points) = [ points[0] * thickness, points[1] * thickness, points[2] * thickness, points[3] * thickness , points[4] * thickness ];
module piece_s3(v1, v2, v3) {
vertex = [ v1 * edge, v2 * edge, v3 * edge ];
points = concat(vertex, interior_s3(vertex));
faces = [
[ 0, 1, 2 ], // top
[ 3, 4, 5 ], // bottom
[ 0, 1, 4, 3 ], // first
[ 1, 2, 5, 4 ], // second
[ 2, 0, 3, 5 ], // third
];
color("blue") polyhedron(points, faces);
};
module piece_s4(v1, v2, v3, v4) {
vertex = [ v1 * edge, v2 * edge, v3 * edge, v4 * edge ];
points = concat(vertex, interior_s4(vertex));
faces = [
[ 0, 1, 2, 3 ], // top
[ 4, 5, 6, 7 ], // bottom
[ 0, 1, 5, 4 ], // back
[ 1, 2, 6, 5 ], // left
[ 2, 3, 7, 6 ], // front
[ 3, 0, 4, 7 ], // right
];
color("yellow") polyhedron(points, faces);
};
module piece_s5(v1, v2, v3, v4, v5) {
vertex = [ v1 * edge, v2 * edge, v3 * edge, v4 * edge, v5 * edge ];
points = concat(vertex, interior_s5(vertex));
faces = [
[ 0, 1, 2, 3, 4 ], // top
[ 5, 6, 7, 8, 9 ], // bottom
[ 0, 1, 6, 5 ], // first
[ 1, 2, 7, 6 ], // second
[ 2, 3, 8, 7 ], // third
[ 3, 4, 9, 8 ], // fourth
[ 4, 0, 5, 9 ], // fifth
];
color("red") polyhedron(points, faces);
};
vertex = [
[ 1, -1, phi3 ], [ 1, 1, phi3 ], [ -1, 1, phi3 ], [ -1, -1, phi3 ], // 0-3
[ phi2, 0, 2+phi ], [ -phi2, 0, 2+phi ], // 4-5
[ phi, phi2, 2*phi ], [ -phi, phi2, 2*phi ], [ -phi, -phi2, 2*phi ], [ phi, -phi2, 2*phi ], // 6-9
[ 2*phi, -phi, phi2 ], [ 2*phi, phi , phi2 ], [ -2*phi , phi, phi2 ], [ -2*phi, -phi, phi2 ], [ 0, 2+phi, phi2 ], [ 0, -2-phi, phi2 ], // 10-15
[ phi2, 2*phi , phi ], [ -phi2, 2*phi , phi ], [ -phi2, -2*phi , phi ], [ phi2, -2*phi , phi ], // 16-19
[ 1, phi3, 1 ], [ -1, phi3, 1 ], [ -1, -phi3, 1 ], [ 1, -phi3, 1 ], [ phi3, -1 , 1 ], [ phi3, 1 , 1 ], [ -phi3, 1 , 1 ], [ -phi3, -1 , 1 ], // 20-27
[ 2+phi, -phi2 , 0 ], [ 2+phi, phi2 , 0 ], [ -2-phi, phi2 , 0 ], [ -2-phi, -phi2 , 0 ], // 28-31
[ phi3, -1, -1 ], [ phi3, 1 , -1 ], [ -phi3, 1 , -1 ], [ -phi3, -1 , -1 ], [ 1, phi3, -1 ], [ -1, phi3, -1 ], [ -1, -phi3, -1 ], [ 1, -phi3, -1 ], // 32-39
[ phi2, 2*phi , -phi ], [ -phi2, 2*phi , -phi ], [ -phi2, -2*phi , -phi ], [ phi2, -2*phi , -phi ], // 40-
];
piece_s4(vertex[0], vertex[1], vertex[2], vertex[3]); // 1 (S4)
piece_s3(vertex[1], vertex[0], vertex[4]); // 2 (S3)
piece_s3(vertex[3], vertex[2], vertex[5]); // 3 (S3)
piece_s5(vertex[2], vertex[1], vertex[6], vertex[14], vertex[7]); // 4 (S5)
piece_s5(vertex[0], vertex[3], vertex[8], vertex[15], vertex[9]); // 5 (S5)
piece_s4(vertex[0], vertex[9], vertex[10], vertex[4]); // 6 (S4)
piece_s4(vertex[1], vertex[4], vertex[11], vertex[6]); // 7 (S4)
piece_s4(vertex[2], vertex[7], vertex[12], vertex[5]); // 8 (S4)
piece_s4(vertex[3], vertex[5], vertex[13], vertex[8]); // 9 (S4)
piece_s3(vertex[6], vertex[11], vertex[16]); // 10 (S3)
piece_s3(vertex[12], vertex[7], vertex[17]); // 11 (S3)
piece_s3(vertex[8], vertex[13], vertex[18]); // 12 (S3)
piece_s3(vertex[10], vertex[9], vertex[19]); // 13 (S3)
piece_s4(vertex[6], vertex[16], vertex[20], vertex[14]); // 14 (S4)
piece_s4(vertex[7], vertex[14], vertex[21], vertex[17]); // 15 (S4)
piece_s4(vertex[8], vertex[18], vertex[22], vertex[15]); // 16 (S4)
piece_s4(vertex[9], vertex[15], vertex[23], vertex[19]); // 17 (S4)
piece_s3(vertex[14], vertex[20], vertex[21]); // 18 (S3)
piece_s3(vertex[15], vertex[22], vertex[23]); // 19 (S3)
piece_s5(vertex[4], vertex[10], vertex[24], vertex[25], vertex[11]); // 20 (S5)
piece_s5(vertex[5], vertex[12], vertex[26], vertex[27], vertex[13]); // 21 (S5)
piece_s4(vertex[10], vertex[19], vertex[28], vertex[24]); // 22 (S4)
piece_s4(vertex[11], vertex[25], vertex[29], vertex[16]); // 23 (S4)
piece_s4(vertex[12], vertex[17], vertex[30], vertex[26]); // 24 (S4)
piece_s4(vertex[13], vertex[27], vertex[31], vertex[18]); // 25 (S4)
piece_s3(vertex[24], vertex[28], vertex[32]); // 26 (S3)
piece_s3(vertex[25], vertex[33], vertex[29]); // 27 (S3)
piece_s3(vertex[26], vertex[30], vertex[34]); // 28 (S3)
piece_s3(vertex[27], vertex[35], vertex[31]); // 29 (S3)
piece_s4(vertex[25], vertex[24], vertex[32], vertex[33]); // 30 (S4)
piece_s4(vertex[27], vertex[26], vertex[34], vertex[35]); // 31 (S4)
piece_s4(vertex[21], vertex[20], vertex[36], vertex[37]); // 32 (S4)
piece_s4(vertex[23], vertex[22], vertex[38], vertex[39]); // 33 (S4)
piece_s5(vertex[16], vertex[29], vertex[40], vertex[36], vertex[20]); // 34 (S5)
piece_s5(vertex[17], vertex[21], vertex[37], vertex[41], vertex[30]); // 35 (S5)
piece_s5(vertex[18], vertex[31], vertex[42], vertex[38], vertex[22]); // 36 (S5)
piece_s5(vertex[19], vertex[23], vertex[39], vertex[43], vertex[28]); // 37 (S5)
// parameters
edge = 10; // 10mm
thickness = 0.9; // -10%
// constants
phi = (1 + sqrt(5)) / 2;
phi2 = phi * phi;
phi3 = phi2 * phi;
// s4_1
v_s4_1 = [
// exterior side
[ 1.0, 1.0, phi3] * edge,
[ -1.0, 1.0, phi3] * edge,
[ -1.0, -1.0, phi3] * edge,
[ 1.0, -1.0, phi3] * edge,
// interior side
[ 1.0, 1.0, phi3] * edge * thickness,
[ -1.0, 1.0, phi3] * edge * thickness,
[ -1.0, -1.0, phi3] * edge * thickness,
[ 1.0, -1.0, phi3] * edge * thickness,
];
f_s4_1 = [
[ 0 , 1, 2, 3 ], // top
[ 4, 5, 6, 7 ], // bottom
[ 0, 1, 5, 4], // back
[1, 2, 6, 5], // left
[2, 3, 7, 6], // front
[3, 0, 4, 7], // right
];
color("yellow") polyhedron( points=v_s4_1, faces=f_s4_1);
// s3_1
v_s3_1 = [
// exterior side
[ 1.0, 1.0, phi3] * edge,
[ 1.0, -1.0, phi3] * edge,
[ phi2, 0, 2 + phi] * edge,
// interior side
[ 1.0, 1.0, phi3] * edge * thickness,
[ 1.0, -1.0, phi3] * edge * thickness,
[ phi2, 0, 2 + phi] * edge * thickness,
];
f_s3_1 = [
[0, 1, 2], // top
[3, 4, 5], // bottom
[2, 0, 3, 5],
[0, 1, 4, 3],
[1, 2, 5, 4],
];
color("blue") polyhedron( points=v_s3_1, faces=f_s3_1);
// s5_1
v_s5_1 = [
// exterior side
[ phi2, 0, 2 + phi] * edge,
[ 2*phi, phi, phi2] * edge,
[ phi3, 1, 1] * edge,
[ phi3, -1, 1] * edge,
[ 2*phi, -phi, phi2] * edge,
// interior side
[ phi2, 0, 2 + phi] * edge * thickness,
[ 2*phi, phi, phi2] * edge * thickness,
[ phi3, 1, 1] * edge * thickness,
[ phi3, -1, 1] * edge * thickness,
[ 2*phi, -phi, phi2] * edge * thickness,
];
f_s5_1 = [
[ 0, 1, 2, 3, 4], // top
[ 5, 6, 7, 8, 9], // bottom
[0, 1, 6, 5],
[1, 2, 7, 6],
[2, 3, 8, 7],
[3, 4, 9, 8],
[4, 0, 5, 9],
];
color("red") polyhedron( points=v_s5_1, faces=f_s5_1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment