aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--designs/blank_d4.scad11
-rw-r--r--designs/blank_d8.scad17
-rw-r--r--designs/epic_level_counter.scad47
-rw-r--r--designs/free_mono_d12.scad31
-rw-r--r--designs/free_mono_d20.scad47
-rw-r--r--designs/free_mono_d4.scad15
-rw-r--r--designs/free_mono_d6.scad17
-rw-r--r--designs/free_mono_d8.scad23
-rw-r--r--designs/fudge.scad17
-rw-r--r--designs/pips_d6.scad17
-rw-r--r--designs/zampa_d12.scad31
-rw-r--r--designs/zampa_d6.scad17
-rw-r--r--lib/dice.scad162
13 files changed, 263 insertions, 189 deletions
diff --git a/designs/blank_d4.scad b/designs/blank_d4.scad
index 5d190ef..498543b 100644
--- a/designs/blank_d4.scad
+++ b/designs/blank_d4.scad
@@ -1,14 +1,5 @@
use <../lib/dice.scad>
-use <../lib/utils.scad>
-use <../lib/faces/empty.scad>
size = 16;
-side = s2s_d4(size);
-
-d4(size) {
- empty(side);
- empty(side);
- empty(side);
- empty(side);
-}
+d4(size);
diff --git a/designs/blank_d8.scad b/designs/blank_d8.scad
index 1c94fbd..4b2dd63 100644
--- a/designs/blank_d8.scad
+++ b/designs/blank_d8.scad
@@ -1,20 +1,5 @@
use <../lib/dice.scad>
-use <../lib/utils.scad>
-use <../lib/faces/empty.scad>
size = 16;
-side = s2s_d8(size);
-
-echo(side);
-
-d8(size) {
- empty(side);
- empty(side);
- empty(side);
- empty(side);
- empty(side);
- empty(side);
- empty(side);
- empty(side);
-}
+d8(size);
diff --git a/designs/epic_level_counter.scad b/designs/epic_level_counter.scad
index b0d3464..c1781c8 100644
--- a/designs/epic_level_counter.scad
+++ b/designs/epic_level_counter.scad
@@ -6,27 +6,30 @@ size = 30;
side = s2s_d20(size);
-echo(side);
+r = side*sqrt(10+2*sqrt(5))/4;
-d20(size) {
- digits(side, 1, "free_mono");
- digits(side, 16, "free_mono");
- digits(side, 3, "free_mono");
- digits(side, 18, "free_mono");
- digits(side, 7, "free_mono");
- digits(side, 11, "free_mono");
- digits(side, 5, "free_mono");
- digits(side, 13, "free_mono");
- digits(side, 10, "free_mono");
- digits(side, 14, "free_mono");
- digits(side, 9, "free_mono");
- digits(side, 15, "free_mono");
- digits(side, 8, "free_mono");
- digits(side, 19, "free_mono");
- digits(side, 6, "free_mono");
- digits(side, 12, "free_mono");
- digits(side, 4, "free_mono");
- digits(side, 17, "free_mono");
- digits(side, 2, "free_mono");
- digits(side, 20, "free_mono");
+difference() {
+ d20(size);
+ icosahedron_faces(r=r) {
+ digits(side, 1, "free_mono");
+ digits(side, 16, "free_mono");
+ digits(side, 3, "free_mono");
+ digits(side, 18, "free_mono");
+ digits(side, 7, "free_mono");
+ digits(side, 11, "free_mono");
+ digits(side, 5, "free_mono");
+ digits(side, 13, "free_mono");
+ digits(side, 10, "free_mono");
+ digits(side, 14, "free_mono");
+ digits(side, 9, "free_mono");
+ digits(side, 15, "free_mono");
+ digits(side, 8, "free_mono");
+ digits(side, 19, "free_mono");
+ digits(side, 6, "free_mono");
+ digits(side, 12, "free_mono");
+ digits(side, 4, "free_mono");
+ digits(side, 17, "free_mono");
+ digits(side, 2, "free_mono");
+ digits(side, 20, "free_mono");
+ }
}
diff --git a/designs/free_mono_d12.scad b/designs/free_mono_d12.scad
index a8168cb..2c9265b 100644
--- a/designs/free_mono_d12.scad
+++ b/designs/free_mono_d12.scad
@@ -6,17 +6,22 @@ size = 14;
side = s2s_d12(size);
-d12(size) {
- digits(side, 1, "free_mono");
- digits(side, 2, "free_mono");
- digits(side, 3, "free_mono");
- digits(side, 4, "free_mono");
- digits(side, 5, "free_mono");
- digits(side, 6, "free_mono");
- digits(side, 7, "free_mono");
- digits(side, 8, "free_mono");
- digits(side, 9, "free_mono");
- digits(side, 10, "free_mono");
- digits(side, 11, "free_mono");
- digits(side, 12, "free_mono");
+r = side*sqrt(3)*(1+sqrt(5))/4;
+
+difference() {
+ d12(size);
+ dodecahedron_faces(r) {
+ digits(side, 1, "free_mono");
+ digits(side, 2, "free_mono");
+ digits(side, 3, "free_mono");
+ digits(side, 4, "free_mono");
+ digits(side, 5, "free_mono");
+ digits(side, 6, "free_mono");
+ digits(side, 7, "free_mono");
+ digits(side, 8, "free_mono");
+ digits(side, 9, "free_mono");
+ digits(side, 10, "free_mono");
+ digits(side, 11, "free_mono");
+ digits(side, 12, "free_mono");
+ }
}
diff --git a/designs/free_mono_d20.scad b/designs/free_mono_d20.scad
index 1ad6e81..77eb431 100644
--- a/designs/free_mono_d20.scad
+++ b/designs/free_mono_d20.scad
@@ -6,25 +6,30 @@ size = 14;
side = s2s_d20(size);
-d20(size) {
- digits(side, 1, "free_mono");
- digits(side, 2, "free_mono");
- digits(side, 3, "free_mono");
- digits(side, 4, "free_mono");
- digits(side, 5, "free_mono");
- digits(side, 6, "free_mono");
- digits(side, 7, "free_mono");
- digits(side, 8, "free_mono");
- digits(side, 9, "free_mono");
- digits(side, 10, "free_mono");
- digits(side, 11, "free_mono");
- digits(side, 12, "free_mono");
- digits(side, 13, "free_mono");
- digits(side, 14, "free_mono");
- digits(side, 15, "free_mono");
- digits(side, 16, "free_mono");
- digits(side, 17, "free_mono");
- digits(side, 18, "free_mono");
- digits(side, 19, "free_mono");
- digits(side, 20, "free_mono");
+r = side*sqrt(10+2*sqrt(5))/4;
+
+difference() {
+ d20(size);
+ icosahedron_faces(r=r) {
+ digits(side, 1, "free_mono");
+ digits(side, 2, "free_mono");
+ digits(side, 3, "free_mono");
+ digits(side, 4, "free_mono");
+ digits(side, 5, "free_mono");
+ digits(side, 6, "free_mono");
+ digits(side, 7, "free_mono");
+ digits(side, 8, "free_mono");
+ digits(side, 9, "free_mono");
+ digits(side, 10, "free_mono");
+ digits(side, 11, "free_mono");
+ digits(side, 12, "free_mono");
+ digits(side, 13, "free_mono");
+ digits(side, 14, "free_mono");
+ digits(side, 15, "free_mono");
+ digits(side, 16, "free_mono");
+ digits(side, 17, "free_mono");
+ digits(side, 18, "free_mono");
+ digits(side, 19, "free_mono");
+ digits(side, 20, "free_mono");
+ }
}
diff --git a/designs/free_mono_d4.scad b/designs/free_mono_d4.scad
index 6ed5dad..9c9826f 100644
--- a/designs/free_mono_d4.scad
+++ b/designs/free_mono_d4.scad
@@ -6,9 +6,14 @@ size = 14;
side = s2s_d4(size);
-d4(size) {
- digits(side, 1, "free_mono");
- digits(side, 2, "free_mono");
- digits(side, 3, "free_mono");
- digits(side, 4, "free_mono");
+r = sqrt(6)/4*side;
+
+difference() {
+ d4(size);
+ tetrahedron_faces(r) {
+ digits(side, 1, "free_mono");
+ digits(side, 2, "free_mono");
+ digits(side, 3, "free_mono");
+ digits(side, 4, "free_mono");
+ }
}
diff --git a/designs/free_mono_d6.scad b/designs/free_mono_d6.scad
index 7e450f2..b12984d 100644
--- a/designs/free_mono_d6.scad
+++ b/designs/free_mono_d6.scad
@@ -6,11 +6,14 @@ size = 14;
side = s2s_d6(size);
-rotate([180, 0, 0]) d6(size) {
- digits(side, 1, "free_mono");
- digits(side, 2, "free_mono");
- digits(side, 3, "free_mono");
- digits(side, 4, "free_mono");
- digits(side, 5, "free_mono");
- digits(side, 6, "free_mono");
+rotate([180, 0, 0]) difference() {
+ d6(size);
+ cube_faces(size) {
+ digits(side, 1, "free_mono");
+ digits(side, 2, "free_mono");
+ digits(side, 3, "free_mono");
+ digits(side, 4, "free_mono");
+ digits(side, 5, "free_mono");
+ digits(side, 6, "free_mono");
+ }
}
diff --git a/designs/free_mono_d8.scad b/designs/free_mono_d8.scad
index 8fc17ad..7e82169 100644
--- a/designs/free_mono_d8.scad
+++ b/designs/free_mono_d8.scad
@@ -6,13 +6,18 @@ size = 14;
side = s2s_d8(size);
-d8(size) {
- digits(side, 1, "free_mono");
- digits(side, 2, "free_mono");
- digits(side, 3, "free_mono");
- digits(side, 4, "free_mono");
- digits(side, 5, "free_mono");
- digits(side, 6, "free_mono");
- digits(side, 7, "free_mono");
- digits(side, 8, "free_mono");
+r = sqrt(2)/2*side;
+
+difference() {
+ d8(size);
+ octahedron_faces(r) {
+ digits(side, 1, "free_mono");
+ digits(side, 2, "free_mono");
+ digits(side, 3, "free_mono");
+ digits(side, 4, "free_mono");
+ digits(side, 5, "free_mono");
+ digits(side, 6, "free_mono");
+ digits(side, 7, "free_mono");
+ digits(side, 8, "free_mono");
+ }
}
diff --git a/designs/fudge.scad b/designs/fudge.scad
index d10e05f..4236571 100644
--- a/designs/fudge.scad
+++ b/designs/fudge.scad
@@ -7,11 +7,14 @@ size = 16;
side = s2s_d6(size);
-rotate([180, 0, 0]) d6(size) {
- empty(side);
- fudge_plus(side);
- fudge_minus(side);
- fudge_plus(side);
- fudge_minus(side);
- empty(side);
+rotate([180, 0, 0]) difference() {
+ d6(size);
+ cube_faces(size) {
+ empty(side);
+ fudge_plus(side);
+ fudge_minus(side);
+ fudge_plus(side);
+ fudge_minus(side);
+ empty(side);
+ }
}
diff --git a/designs/pips_d6.scad b/designs/pips_d6.scad
index 8a5fe16..24a0c8b 100644
--- a/designs/pips_d6.scad
+++ b/designs/pips_d6.scad
@@ -6,11 +6,14 @@ size = 16;
side = s2s_d6(size);
-rotate([180, 0, 0]) d6(size) {
- pips_1(side);
- pips_2(side);
- pips_3(side);
- pips_4(side);
- pips_5(side);
- pips_6(side);
+rotate([180, 0, 0]) difference() {
+ d6(size);
+ cube_faces(size) {
+ pips_1(side);
+ pips_2(side);
+ pips_3(side);
+ pips_4(side);
+ pips_5(side);
+ pips_6(side);
+ }
}
diff --git a/designs/zampa_d12.scad b/designs/zampa_d12.scad
index 691e2f5..7f5016b 100644
--- a/designs/zampa_d12.scad
+++ b/designs/zampa_d12.scad
@@ -7,17 +7,22 @@ size = 14;
side = s2s_d12(size);
-d12(size) {
- gfx(side, "zampa");
- digits(side, 2, "free_mono");
- digits(side, 3, "free_mono");
- digits(side, 4, "free_mono");
- digits(side, 5, "free_mono");
- digits(side, 6, "free_mono");
- digits(side, 7, "free_mono");
- digits(side, 8, "free_mono");
- digits(side, 9, "free_mono");
- digits(side, 10, "free_mono");
- digits(side, 11, "free_mono");
- digits(side, 12, "free_mono");
+r = side*sqrt(3)*(1+sqrt(5))/4;
+
+difference() {
+ d12(size);
+ dodecahedron_faces(r=r) {
+ gfx(side, "zampa");
+ digits(side, 2, "free_mono");
+ digits(side, 3, "free_mono");
+ digits(side, 4, "free_mono");
+ digits(side, 5, "free_mono");
+ digits(side, 6, "free_mono");
+ digits(side, 7, "free_mono");
+ digits(side, 8, "free_mono");
+ digits(side, 9, "free_mono");
+ digits(side, 10, "free_mono");
+ digits(side, 11, "free_mono");
+ digits(side, 12, "free_mono");
+ }
}
diff --git a/designs/zampa_d6.scad b/designs/zampa_d6.scad
index f2e10cf..2d486df 100644
--- a/designs/zampa_d6.scad
+++ b/designs/zampa_d6.scad
@@ -7,11 +7,14 @@ size = 14;
side = s2s_d6(size);
-rotate([0, 0, 0]) d6(size) {
- gfx(side, "zampa");
- digits(side, 2, "free_mono");
- digits(side, 3, "free_mono");
- digits(side, 4, "free_mono");
- digits(side, 5, "free_mono");
- digits(side, 6, "free_mono");
+difference() {
+ d6(size);
+ cube_faces(side) {
+ gfx(side, "zampa");
+ digits(side, 2, "free_mono");
+ digits(side, 3, "free_mono");
+ digits(side, 4, "free_mono");
+ digits(side, 5, "free_mono");
+ digits(side, 6, "free_mono");
+ }
}
diff --git a/lib/dice.scad b/lib/dice.scad
index b14d315..58d00e8 100644
--- a/lib/dice.scad
+++ b/lib/dice.scad
@@ -1,22 +1,19 @@
use <utils.scad>
-module d4(size=false, side=false) {
- l = side ? side : s2s_d4(size);
- if (l == false) {
- echo("ERROR: d4: one of side or size should be defined");
- }
- sc_face = 0.6;
- r = sqrt(6)/4*l;
+// Tetrahedron inscribed in a sphere of radius r
+module tetrahedron(r) {
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);
- }
+ intersection() {
+ 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);
}
+ }
+}
+
+module tetrahedron_faces(r, sc_face=0.6) {
+ union() {
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);
@@ -24,16 +21,22 @@ module d4(size=false, side=false) {
}
}
-module d6(size=false, side=false) {
- l = side ? side : s2s_d6(size);
+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");
+ echo("ERROR: d4: one of side or size should be defined");
}
+ r = sqrt(6)/4*l;
difference() {
intersection() {
- cube(l, center=true);
- sphere(l*0.79);
+ sphere(r=r*0.79, $fn=64);
+ tetrahedron(r);
}
+ }
+}
+
+module cube_faces(l) {
+ union() {
translate([0, 0, l/2]) child(0);
rotate([90, 0, 0]) translate([0, 0, l/2]) child(1);
rotate([0, 90, 0]) translate([0, 0, l/2]) child(2);
@@ -43,24 +46,35 @@ module d6(size=false, side=false) {
}
}
-module d8(size=false, side=false) {
- l = side ? side : s2s_d8(size);
+module d6(size=false, side=false) {
+ l = side ? side : s2s_d6(size);
if (l == false) {
- echo("ERROR: d8: one of side or size should be defined");
+ echo("ERROR: d6: 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;
difference() {
intersection() {
- sphere(r*0.86, $fn=64);
- cube([c, c, i_r*2], center=true);
- intersection_for ( i = [0:2] ) {
+ cube(l, center=true);
+ sphere(l*0.79);
+ }
+ }
+}
- rotate([0, 0, 120*i]) rotate([acos(-1/3), 0, 0]) cube([c, c, i_r*2], center=true);
- }
+// Octahedron inscribed in a sphere of radius r
+module octahedron(r) {
+ c = r*2;
+ i_r = r / sqrt(3);
+ intersection() {
+ cube([c, c, i_r*2], center=true);
+ intersection_for ( i = [0:2] ) {
+ rotate([0, 0, 120*i]) rotate([acos(-1/3), 0, 0]) cube([c, c, i_r*2], center=true);
}
+ }
+}
+
+module octahedron_faces(r, sc_face=0.6) {
+ c = r*2;
+ i_r = r / sqrt(3);
+ union() {
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);
@@ -72,24 +86,37 @@ module d8(size=false, side=false) {
}
}
-module d12(size=false, side=false) {
- l = side ? side : s2s_d12(size);
+module d8(size=false, side=false) {
+ l = side ? side : s2s_d8(size);
if (l == false) {
- echo("ERROR: d12: one of side or size should be defined");
+ echo("ERROR: d8: one of side or size should be defined");
}
- sc_face = 1.1;
- r = l*sqrt(3)*(1+sqrt(5))/4;
+ r = sqrt(2)/2*l;
+ intersection() {
+ sphere(r*0.86, $fn=64);
+ octahedron(r);
+ }
+}
+
+// Dodecahedron inscribed in a sphere of radius r
+module dodecahedron(r) {
c = r*2;
+ l = r * 4 / (sqrt(3) * (1+sqrt(5)));
i_r = (l/2)*sqrt(5/2 + 11*sqrt(5)/10);
- difference() {
- intersection() {
- sphere(r*0.96, $fn=64);
- cube([c, c, i_r*2], center=true);
- intersection_for ( i = [0:4] ) {
-
- rotate([0, 0, 72*i]) rotate([acos(-1/sqrt(5)), 0, 0]) cube([c, c, i_r*2], center=true);
- }
+ intersection() {
+ cube([c, c, i_r*2], center=true);
+ intersection_for ( i = [0:4] ) {
+ rotate([0, 0, 72*i]) rotate([acos(-1/sqrt(5)), 0, 0]) cube([c, c, i_r*2], center=true);
}
+ }
+}
+
+module dodecahedron_faces(r, sc_face=1.1) {
+ c = r*2;
+ l = r * 4 / (sqrt(3) * (1+sqrt(5)));
+ echo(l);
+ i_r = (l/2)*sqrt(5/2 + 11*sqrt(5)/10);
+ union() {
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);
@@ -106,21 +133,28 @@ module d12(size=false, side=false) {
}
}
-module d20(size=false, side=false) {
- l = side ? side : s2s_d20(size);
+module d12(size=false, side=false) {
+ l = side ? side : s2s_d12(size);
if (l == false) {
- echo("ERROR: d20: one of side or size should be defined");
+ echo("ERROR: d12: one of side or size should be defined");
}
- sc_face = 0.5;
- r = l*sqrt(10+2*sqrt(5))/4;
+ r = l*sqrt(3)*(1+sqrt(5))/4;
+ intersection() {
+ sphere(r*0.96, $fn=64);
+ dodecahedron(r);
+ }
+}
+
+module icosahedron(r) {
+ l = r*4/(sqrt(10+2*sqrt(5)));
+ echo(r);
+ echo(l);
c = r*2;
i_r = (l/12)*sqrt(3)*(3+sqrt(5));
a_b2 = atan(1/2) + acos(-sqrt(5)/3)/2;
phi = (1+sqrt(5))/2;
rotate([0, -acos((-(1+sqrt(5)))/(2*sqrt(3))), 0])
- difference() {
intersection() {
- sphere(r*0.96, $fn=64);
rotate([0, acos((-(1+sqrt(5)))/(2*sqrt(3))), 0]) cube([c, c, i_r*2], center=true);
mirror([1, 0, 0]) rotate([0, acos((-(1+sqrt(5)))/(2*sqrt(3))), 0]) cube([c, c, i_r*2], center=true);
rotate([0, acos(1/sqrt(3)), -45]) cube([c, c, i_r*2], center=true);
@@ -132,6 +166,18 @@ module d20(size=false, side=false) {
rotate([0, 90, atan((-sqrt(5)+1)/(sqrt(5)+1))]) cube([c, c, i_r*2], center=true);
mirror([0, 1, 0]) rotate([0, 90, atan((-sqrt(5)+1)/(sqrt(5)+1))]) cube([c, c, i_r*2], center=true);
}
+}
+
+module icosahedron_faces(r, sc_face=0.5) {
+ l = r*4/(sqrt(10+2*sqrt(5)));
+ echo(r);
+ echo(l);
+ c = r*2;
+ i_r = (l/12)*sqrt(3)*(3+sqrt(5));
+ a_b2 = atan(1/2) + acos(-sqrt(5)/3)/2;
+ phi = (1+sqrt(5))/2;
+ rotate([0, -acos((-(1+sqrt(5)))/(2*sqrt(3))), 0])
+ union() {
rotate([0, acos((-(1+sqrt(5)))/(2*sqrt(3))), 0]) translate([0, 0, i_r]) rotate([0, 0, 90]) scale([sc_face, sc_face, 1]) child(0);
rotate([180, acos((-(1+sqrt(5)))/(2*sqrt(3))), 0]) translate([0, 0, i_r]) rotate([0, 0, 270]) scale([sc_face, sc_face, 1]) child(19);
@@ -164,3 +210,15 @@ module d20(size=false, side=false) {
}
}
+module d20(size=false, side=false) {
+ l = side ? side : s2s_d20(size);
+ if (l == false) {
+ echo("ERROR: d20: one of side or size should be defined");
+ }
+ r = l*sqrt(10+2*sqrt(5))/4;
+ intersection() {
+ sphere(r*0.96, $fn=64);
+ icosahedron(r);
+ }
+}
+