aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena of Valhalla'' Grandi <valhalla@trueelena.org>2014-06-22 12:33:55 +0200
committerElena of Valhalla'' Grandi <valhalla@trueelena.org>2014-06-22 12:33:55 +0200
commitc6b16f80c6158c4ec07ca30be5ca87cd8d7b326c (patch)
treedd819a6b5b7701b7b055ad8f740a45161cf459fa
parent10b38e77082ad8df31f0e5e4d9d7ee62a1634c78 (diff)
Add d4 and size to side util functions
-rw-r--r--designs/pips_d6.scad8
-rw-r--r--lib/dice.scad30
-rw-r--r--lib/utils.scad7
3 files changed, 39 insertions, 6 deletions
diff --git a/designs/pips_d6.scad b/designs/pips_d6.scad
index 2f82ff4..8a5fe16 100644
--- a/designs/pips_d6.scad
+++ b/designs/pips_d6.scad
@@ -1,10 +1,12 @@
use <../lib/dice.scad>
+use <../lib/utils.scad>
use <../lib/faces/pips.scad>
-side = 14;
-size = 14;
+size = 16;
-rotate([180, 0, 0]) d6(side, size) {
+side = s2s_d6(size);
+
+rotate([180, 0, 0]) d6(size) {
pips_1(side);
pips_2(side);
pips_3(side);
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 <utils.scad>
+
+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);
diff --git a/lib/utils.scad b/lib/utils.scad
new file mode 100644
index 0000000..d849636
--- /dev/null
+++ b/lib/utils.scad
@@ -0,0 +1,7 @@
+
+function circ_rad(size) = size / sqrt(2);
+
+function s2s_d4(size) = circ_rad(size)*2/sqrt(6);
+
+function s2s_d6(size) = size;
+