From c6b16f80c6158c4ec07ca30be5ca87cd8d7b326c Mon Sep 17 00:00:00 2001 From: Elena of Valhalla'' Grandi Date: Sun, 22 Jun 2014 12:33:55 +0200 Subject: Add d4 and size to side util functions --- lib/dice.scad | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'lib/dice.scad') diff --git a/lib/dice.scad b/lib/dice.scad index c3cab85..ed63d3f 100644 --- a/lib/dice.scad +++ b/lib/dice.scad @@ -1,9 +1,33 @@ -module d6(side=false, size=false) { - l = side ? side : size; +use + +module d4(size=false, side=false) { + l = side ? side : s2s_d4(size); + if (l == false) { + echo("ERROR: d6: one of side or size should be defined"); + } + r = sqrt(6)/4*l; + c = r*2; + difference() { + intersection() { + sphere(r=r*0.79, $fn=64); + translate([0, 0, r-r/3]) cube(c, center=true); + intersection_for ( i = [0:2] ) { + rotate([0, 0, 120*i]) rotate([acos(1/3)+180, 0, 0]) + 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); + } +} + +module d6(size=false, side=false) { + l = side ? side : s2s_d6(size); if (l == false) { echo("ERROR: d6: one of side or size should be defined"); } - echo(l); difference() { intersection() { cube(l, center=true); -- cgit v1.2.3