add erin's puzzle and its solution
[ozzloy@gmail.com/3d-printables] / erin / puzzle.scad
diff --git a/erin/puzzle.scad b/erin/puzzle.scad
new file mode 100644 (file)
index 0000000..937df00
--- /dev/null
@@ -0,0 +1,159 @@
+$fn = 100;
+
+h = 10;
+
+module pyramid() {
+polyhedron(
+    points=[
+        [h,h,0], [h,-h,0], [-h,-h,0], [-h,h,0], [0,0,h]
+    ],
+    faces = [
+        [1,4,0], [2,4,1], [2,3,4], [4,3,0],
+        [0,3,2,1]
+    ]
+);
+}
+
+module quarter_pyramid() {
+    difference() {
+        pyramid();
+        rotate([0,0,45]) translate([-2*h, 0, -h]) cube([h*4,h*4,h*4]);
+        rotate([0,0,-45]) translate([-2*h, -4*h, -h]) cube([h*4,h*4,h*4]);
+        rotate([0,0,-45]) translate([0, -4*h, -h]) cube([h*4,h*4,h*4]);
+    }
+//polyhedron(
+//    points=[
+//        [0,0,0], [h,h,0], [h,-h,0], [0,0,h]
+//    ],
+//    faces = [
+//        [1,2,3], [3,1,0], 
+//    ]
+//);
+}
+
+//quarter_pyramid();
+
+module bottom() {
+    children();
+}
+
+module top() {
+    translate([0,0,2*h]) rotate([180,0,0])
+    children();
+}
+
+module north() {
+    translate([0,h,h]) rotate([90,90,0])
+    children();
+}
+
+module south() {
+    rotate([0,0,180]) north()
+    children();
+}
+
+module east() {
+    translate([h,0,h]) rotate([90,0,0]) rotate([0,-90,0])
+    children();
+}
+
+module west() {
+    rotate([0,0,180]) east()
+    children();
+}
+
+module pointy() {
+    translate([0,0,-2*h]) top() pyramid();
+}
+
+
+module partA() {
+    translate([0,-h,-h]) rotate([180,-90,90]) quarter_pyramid();
+}
+
+
+module partB() {
+    translate([0,-h,-h]) rotate([180,-90,-90]) quarter_pyramid();
+}
+
+//top() pyramid();
+//top() pointy();
+//top() partA();
+//top() partB();
+//top() partC();
+//top() partD();
+//top() partE();
+
+//south() pyramid();
+//south() pointy();
+//south() partA();
+//south() partB();
+//south() partC();
+//south() partD();
+//south() partE();
+
+//north() pyramid();
+//north() pointy();
+//north() partA();
+//north() partB();
+//north() partC();
+//north() partD();
+//north() partE();
+
+//west() pyramid();
+//west() pointy();
+//west() partA();
+//west() partB();
+//west() partC();
+//west() partD();
+//west() partE();
+
+//east() pyramid();
+//east() pointy();
+//east() partA();
+//east() partB();
+//east() partC();
+//east() partD();
+//east() partE();
+
+module partC() {
+    translate([-h,h,-h]) rotate([0,180,90]) {
+        partA(); partB();
+    }
+}
+
+
+//bottom() pyramid();
+//bottom() pointy();
+//bottom() partA();
+//bottom() partB();
+//bottom() partC();
+//bottom() partD();
+//bottom() partE();
+
+module partD() {
+    translate([0,h,-h]) rotate([90, 0, 0]) partC();
+}
+
+module partE() {
+    rotate([0,0,180]) partD();
+}
+
+module puzzle_piece() {
+    pyramid();
+    pointy();
+    partA();
+    partB();
+    partC();
+    partD();
+    partE();
+}
+
+rotate([0,45,0]) puzzle_piece();
+
+//bottom() puzzle_piece();
+//top() puzzle_piece();
+//north() puzzle_piece();
+//south() puzzle_piece();
+//east() puzzle_piece();
+//west() puzzle_piece();