271bfd5f |
1 | $fn = 100; |
2 | |
3 | h = 10; |
4 | |
64c08061 |
5 | module block() { |
6 | translate([-h, -h]) |
7 | cube([2*h, 2*h, h]); |
8 | }; |
9 | |
10 | module cut() { |
11 | translate([0, -h/2, h/2]) |
12 | rotate([45, 0, 0]) |
13 | translate([-1.5*h, -1.5*h]) |
14 | cube([3*h, 3*h, h]); |
15 | }; |
16 | |
271bfd5f |
17 | module pyramid() { |
64c08061 |
18 | difference() { |
19 | block(); |
20 | cut(); |
21 | rotate(90) cut(); |
22 | rotate(180) cut(); |
23 | rotate(270) cut(); |
24 | } |
25 | }; |
26 | |
27 | //polyhedron( |
28 | // points=[ |
29 | // [h,h,0], [h,-h,0], [-h,-h,0], [-h,h,0], [0,0,h] |
30 | // ], |
31 | // faces = [ |
32 | // [1,4,0], [2,4,1], [2,3,4], [4,3,0], |
33 | // [0,3,2,1] |
34 | // ] |
35 | //); |
271bfd5f |
36 | |
37 | module quarter_pyramid() { |
38 | difference() { |
39 | pyramid(); |
40 | rotate([0,0,45]) translate([-2*h, 0, -h]) cube([h*4,h*4,h*4]); |
41 | rotate([0,0,-45]) translate([-2*h, -4*h, -h]) cube([h*4,h*4,h*4]); |
42 | rotate([0,0,-45]) translate([0, -4*h, -h]) cube([h*4,h*4,h*4]); |
43 | } |
64c08061 |
44 | }; |
271bfd5f |
45 | |
46 | //quarter_pyramid(); |
47 | |
48 | module bottom() { |
49 | children(); |
64c08061 |
50 | }; |
271bfd5f |
51 | |
52 | module top() { |
53 | translate([0,0,2*h]) rotate([180,0,0]) |
54 | children(); |
64c08061 |
55 | }; |
271bfd5f |
56 | |
57 | module north() { |
58 | translate([0,h,h]) rotate([90,90,0]) |
59 | children(); |
64c08061 |
60 | }; |
271bfd5f |
61 | |
62 | module south() { |
63 | rotate([0,0,180]) north() |
64 | children(); |
64c08061 |
65 | }; |
271bfd5f |
66 | |
67 | module east() { |
68 | translate([h,0,h]) rotate([90,0,0]) rotate([0,-90,0]) |
69 | children(); |
64c08061 |
70 | }; |
271bfd5f |
71 | |
72 | module west() { |
73 | rotate([0,0,180]) east() |
74 | children(); |
64c08061 |
75 | }; |
271bfd5f |
76 | |
77 | module pointy() { |
78 | translate([0,0,-2*h]) top() pyramid(); |
64c08061 |
79 | }; |
271bfd5f |
80 | |
81 | module partA() { |
82 | translate([0,-h,-h]) rotate([180,-90,90]) quarter_pyramid(); |
64c08061 |
83 | }; |
271bfd5f |
84 | |
85 | module partB() { |
86 | translate([0,-h,-h]) rotate([180,-90,-90]) quarter_pyramid(); |
64c08061 |
87 | }; |
271bfd5f |
88 | |
89 | module partC() { |
90 | translate([-h,h,-h]) rotate([0,180,90]) { |
64c08061 |
91 | union() { |
92 | partA(); |
93 | partB(); |
94 | } |
271bfd5f |
95 | } |
64c08061 |
96 | }; |
271bfd5f |
97 | |
98 | module partD() { |
99 | translate([0,h,-h]) rotate([90, 0, 0]) partC(); |
100 | } |
101 | |
102 | module partE() { |
103 | rotate([0,0,180]) partD(); |
104 | } |
105 | |
106 | module puzzle_piece() { |
107 | pyramid(); |
108 | pointy(); |
109 | partA(); |
110 | partB(); |
111 | partC(); |
112 | partD(); |
113 | partE(); |
114 | } |
115 | |
64c08061 |
116 | module cutout() { |
117 | translate([0, -2.8, 0]) |
118 | rotate([45, 45, 0]) |
119 | translate([-h, -h, 0]) |
120 | translate([0, 4.2, 4.2]) |
121 | cube([2*h, 2*h, 2*h]); |
122 | } |
123 | |
124 | module puzzle_part(){ |
125 | difference() { |
126 | rotate([0,45,0]) puzzle_piece(); |
127 | cutout(); |
128 | translate([0, 2*h, 0]) |
129 | cutout(); |
130 | |
131 | mirror([0, 180, 0]) |
132 | translate([4, -15, h]) |
133 | rotate([45, 0, 45]) |
134 | block(); |
135 | |
136 | translate([4, -15, h]) |
137 | rotate([45, 0, 45]) |
138 | block(); |
139 | }} |
140 | |
141 | // |
142 | module solved_puzzle(){ |
143 | bottom() puzzle_piece(); |
144 | top() puzzle_piece(); |
145 | north() puzzle_piece(); |
146 | south() puzzle_piece(); |
147 | east() puzzle_piece(); |
148 | west() puzzle_piece(); |
149 | } |
150 | |
151 | module step_0(){ |
152 | bottom() puzzle_piece(); |
153 | south() puzzle_piece(); |
154 | west() puzzle_piece(); |
155 | } |
156 | |
157 | module step_1(){ |
158 | bottom() puzzle_piece(); |
159 | south() puzzle_piece(); |
160 | east() puzzle_piece(); |
161 | west() puzzle_piece(); |
162 | } |
163 | |
164 | module step_2(){ |
165 | bottom() puzzle_piece(); |
166 | south() puzzle_piece(); |
167 | east() puzzle_piece(); |
168 | west() puzzle_piece(); |
169 | north() puzzle_piece(); |
170 | } |
271bfd5f |
171 | |
64c08061 |
172 | step_2(); |