From 4f2f026701a4237c3ae916f94109dae67c35d0f5 Mon Sep 17 00:00:00 2001 From: Elena of Valhalla'' Grandi Date: Sun, 29 Jun 2014 11:18:39 +0200 Subject: Scaling of faces and fixed orientation --- lib/dice.scad | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'lib') diff --git a/lib/dice.scad b/lib/dice.scad index c1b2176..b14d315 100644 --- a/lib/dice.scad +++ b/lib/dice.scad @@ -5,6 +5,7 @@ module d4(size=false, side=false) { if (l == false) { echo("ERROR: d4: one of side or size should be defined"); } + sc_face = 0.6; r = sqrt(6)/4*l; c = r*2; difference() { @@ -16,10 +17,10 @@ module d4(size=false, side=false) { translate([0, 0, r-r/3]) cube(c, center=true); } } - rotate([180, 0, 0]) translate([0, 0, r/3]) child(0); - rotate([acos(1/3)+180, 0, 0]) rotate([180, 0, 0]) translate([0, 0, r/3]) child(1); - rotate([0, 0, 120]) rotate([acos(1/3)+180, 0, 0]) rotate([180, 0, 0]) translate([0, 0, r/3]) child(2); - rotate([0, 0, 240]) rotate([acos(1/3)+180, 0, 0]) rotate([180, 0, 0]) translate([0, 0, r/3]) child(3); + rotate([180, 0, 180]) translate([0, 0, r/3]) scale([sc_face, sc_face, 1]) child(0); + rotate([acos(1/3)+180, 0, 0]) rotate([180, 0, 0]) translate([0, 0, r/3]) scale([sc_face, sc_face, 1]) child(1); + rotate([0, 0, 120]) rotate([acos(1/3)+180, 0, 0]) rotate([180, 0, 0]) translate([0, 0, r/3]) scale([sc_face, sc_face, 1]) child(2); + rotate([0, 0, 240]) rotate([acos(1/3)+180, 0, 0]) rotate([180, 0, 0]) translate([0, 0, r/3]) scale([sc_face, sc_face, 1]) child(3); } } @@ -47,6 +48,7 @@ module d8(size=false, side=false) { if (l == false) { echo("ERROR: d8: one of side or size should be defined"); } + sc_face = 0.6; r = sqrt(2)/2*l; c = r*2; i_r = sqrt(6)/6*l; @@ -59,14 +61,14 @@ module d8(size=false, side=false) { rotate([0, 0, 120*i]) rotate([acos(-1/3), 0, 0]) cube([c, c, i_r*2], center=true); } } - translate([0, 0, i_r]) child(0); - rotate([acos(-1/3), 0, 0]) translate([0, 0, i_r]) child(1); - rotate([0, 0, 120]) rotate([acos(-1/3)+180, 0, 0]) translate([0, 0, i_r]) child(2); - rotate([0, 0, -120]) rotate([acos(-1/3)+180, 0, 0]) translate([0, 0, i_r]) child(3); - rotate([0, 0, -120]) rotate([acos(-1/3), 0, 0]) translate([0, 0, i_r]) child(4); - rotate([0, 0, 120]) rotate([acos(-1/3), 0, 0]) translate([0, 0, i_r]) child(5); - rotate([acos(-1/3)+180, 0, 0]) translate([0, 0, i_r]) child(6); - rotate([180, 0, 0]) translate([0, 0, i_r]) child(0); + translate([0, 0, i_r]) rotate([0, 0, 180]) scale([sc_face, sc_face, 1]) child(0); + rotate([acos(-1/3), 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(4); + rotate([0, 0, 120]) rotate([acos(-1/3)+180, 0, 0]) translate([0, 0, i_r]) rotate([0, 0, 120]) scale([sc_face, sc_face, 1]) child(6); + rotate([0, 0, -120]) rotate([acos(-1/3)+180, 0, 0]) rotate([0, 0, 240]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(2); + rotate([0, 0, -120]) rotate([acos(-1/3), 0, 0]) rotate([0, 0, 120]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(5); + rotate([0, 0, 120]) rotate([acos(-1/3), 0, 0]) rotate([0, 0, 240]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(1); + rotate([acos(-1/3)+180, 0, 0]) translate([0, 0, i_r])scale([sc_face, sc_face, 1]) child(3); + rotate([180, 0, 0]) translate([0, 0, i_r])scale([sc_face, sc_face, 1]) child(7); } } @@ -75,6 +77,7 @@ module d12(size=false, side=false) { if (l == false) { echo("ERROR: d12: one of side or size should be defined"); } + sc_face = 1.1; r = l*sqrt(3)*(1+sqrt(5))/4; c = r*2; i_r = (l/2)*sqrt(5/2 + 11*sqrt(5)/10); @@ -87,19 +90,19 @@ module d12(size=false, side=false) { rotate([0, 0, 72*i]) rotate([acos(-1/sqrt(5)), 0, 0]) cube([c, c, i_r*2], center=true); } } - translate([0, 0, i_r]) child(0); - rotate([acos(-1/sqrt(5))+180, 0, 0]) translate([0, 0, i_r]) child(1); - rotate([0, 0, 72]) rotate([acos(-1/sqrt(5))+180, 0, 0]) translate([0, 0, i_r]) child(3); - rotate([0, 0, 144]) rotate([acos(-1/sqrt(5))+180, 0, 0]) translate([0, 0, i_r]) child(5); - rotate([0, 0, 216]) rotate([acos(-1/sqrt(5))+180, 0, 0]) translate([0, 0, i_r]) child(4); - rotate([0, 0, 288]) rotate([acos(-1/sqrt(5))+180, 0, 0]) translate([0, 0, i_r]) child(2); - - rotate([acos(-1/sqrt(5)), 0, 0]) translate([0, 0, i_r]) child(10); - rotate([0, 0, 72]) rotate([acos(-1/sqrt(5)), 0, 0]) translate([0, 0, i_r]) child(8); - rotate([0, 0, 144]) rotate([acos(-1/sqrt(5)), 0, 0]) translate([0, 0, i_r]) child(6); - rotate([0, 0, 216]) rotate([acos(-1/sqrt(5)), 0, 0]) translate([0, 0, i_r]) child(7); - rotate([0, 0, 288]) rotate([acos(-1/sqrt(5)), 0, 0]) translate([0, 0, i_r]) child(9); - rotate([180, 0, 0]) translate([0, 0, i_r]) child(11); + translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(0); + rotate([acos(-1/sqrt(5))+180, 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(1); + rotate([0, 0, 72]) rotate([acos(-1/sqrt(5))+180, 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(3); + rotate([0, 0, 144]) rotate([acos(-1/sqrt(5))+180, 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(5); + rotate([0, 0, 216]) rotate([acos(-1/sqrt(5))+180, 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(4); + rotate([0, 0, 288]) rotate([acos(-1/sqrt(5))+180, 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(2); + + rotate([acos(-1/sqrt(5)), 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(10); + rotate([0, 0, 72]) rotate([acos(-1/sqrt(5)), 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(8); + rotate([0, 0, 144]) rotate([acos(-1/sqrt(5)), 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(6); + rotate([0, 0, 216]) rotate([acos(-1/sqrt(5)), 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(7); + rotate([0, 0, 288]) rotate([acos(-1/sqrt(5)), 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(9); + rotate([180, 0, 0]) translate([0, 0, i_r]) scale([sc_face, sc_face, 1]) child(11); } } -- cgit v1.2.3