818dd661 |
1 | /* GNU AGPLv3 (or later at your option) |
2 | see bottom for more license info */ |
3 | |
4 | /* spin thing that erin likes */ |
cc410ed6 |
5 | $fn = 50; |
6 | |
5f8325d2 |
7 | layer_height = 0.35; |
818dd661 |
8 | |
9 | weight = "penny"; |
10 | // weight = "608zz"; |
3e3691aa |
11 | bearing = "608zz"; |
cc410ed6 |
12 | weight_lip_overhang = 0.3; |
13 | bearing_lip_overhang = weight_lip_overhang; |
cc410ed6 |
14 | wall = 3; |
2645ef26 |
15 | penny_thickness = 1.52; |
818dd661 |
16 | penny_radius = 19.05 / 2; |
7f1519fb |
17 | |
18 | _608zz_radius = 22 / 2; |
19 | _608zz_inner_radius = 8.1 / 2; |
8d55712b |
20 | _608zz_cover_radius = _608zz_radius; |
7f1519fb |
21 | _608zz_cap_footprint_radius = 12 / 2; |
22 | _608zz_thickness = 7; |
23 | |
818dd661 |
24 | weight_radius = (weight == "penny") ? penny_radius : _608zz_radius; |
2645ef26 |
25 | weight_thickness = (weight == "penny") ? |
26 | penny_thickness * 5 : _608zz_thickness; |
7f1519fb |
27 | |
3e3691aa |
28 | bearing_radius = (bearing == "608zz") ? _608zz_radius : 1/0; |
3381230e |
29 | bearing_window_radius = bearing_radius - bearing_lip_overhang - 1; |
7f1519fb |
30 | bearing_inner_radius = (bearing == "608zz") ? _608zz_inner_radius : 1/0; |
31 | bearing_cover_radius = (bearing == "608zz") |
8d55712b |
32 | ? _608zz_cover_radius |
7f1519fb |
33 | : 1/0; |
34 | bearing_cap_footprint_radius = |
35 | (bearing == "608zz") ? _608zz_cap_footprint_radius : 1/0; |
2645ef26 |
36 | bearing_thickness = (bearing == "608zz") ? _608zz_thickness : 1/0; |
7f1519fb |
37 | |
38 | spinner_height = penny_thickness * 5 + 2; |
818dd661 |
39 | arms = 3; |
40 | |
7f1519fb |
41 | module cap(bearing_inner_radius, |
42 | bearing_cap_footprint_radius, |
43 | bearing_cover_radius, |
3381230e |
44 | bearing_thickness, |
45 | bearing_window_radius) { |
46 | footprint_height = 4.5; |
47 | footprint_radius_safety = 0.2; |
7f1519fb |
48 | cap_height = 3; |
3381230e |
49 | bearing_thickness_safety = 0.6; |
50 | finger_spot_height = cap_height / 10; |
7f1519fb |
51 | |
52 | difference() { |
53 | union() { |
54 | cylinder(r1 = bearing_cover_radius - tan(30) * cap_height, |
55 | r2 = bearing_cover_radius, |
56 | h = cap_height); |
3381230e |
57 | linear_extrude(height = cap_height |
58 | + footprint_height |
59 | - 1.05) { |
60 | circle(bearing_window_radius - 1); } |
7f1519fb |
61 | linear_extrude(height = cap_height + footprint_height) { |
62 | circle(bearing_cap_footprint_radius - footprint_radius_safety); } |
63 | linear_extrude(height = cap_height |
64 | + footprint_height |
65 | + bearing_thickness / 2 |
66 | - bearing_thickness_safety) { |
3381230e |
67 | circle(bearing_inner_radius); } |
68 | } |
7f1519fb |
69 | translate([0, 0, -0.01]) { |
3381230e |
70 | cylinder(r1 = bearing_inner_radius, |
71 | r2 = bearing_inner_radius - tan(30) * finger_spot_height, |
72 | h = finger_spot_height); } } } |
7f1519fb |
73 | |
d4c56d9d |
74 | module donut(height, footprint_radius) { |
75 | bread_radius = height / 2; |
76 | rotate_extrude() { |
77 | translate([footprint_radius, 0]) { |
78 | circle(bread_radius); } } } |
79 | |
80 | module donut_hole(height, footprint_radius) { |
81 | difference() { |
82 | cylinder(r = footprint_radius, h = height, center = true); |
83 | donut(height, footprint_radius); } } |
84 | |
85 | module jelly_filled(height, footprint_radius) { |
86 | cylinder(r = footprint_radius, h = height, center = true); |
87 | donut(height, footprint_radius); } |
88 | |
cc410ed6 |
89 | module fillet(r) { |
90 | offset(r = -r) { offset(delta = r) { children(); } } } |
91 | |
cc410ed6 |
92 | module mirrored(axis) { |
93 | children(); |
94 | mirror(axis) children(); } |
2645ef26 |
95 | |
5f8325d2 |
96 | module spin_slice(weight_radius, |
97 | bearing_radius, |
98 | round_extra, |
99 | wall, |
100 | arms) { |
101 | joiner_radius = (bearing_radius + weight_radius) / 2; |
102 | |
103 | bearing_xy = [0, 0]; |
104 | // a = side along x axis |
105 | a = bearing_radius + weight_radius + wall; |
106 | // b = side from center to joiner |
107 | b = bearing_radius + joiner_radius + round_extra; |
108 | // c = side between joiner and arm center |
109 | c = joiner_radius + weight_radius + round_extra; |
110 | |
111 | weight_xy = [a, 0]; |
112 | |
113 | cos_C = (pow(a, 2) + pow(b, 2) - pow(c, 2)) / (2 * a * b); |
114 | sin_C = sqrt(1 - pow(cos_C, 2)); |
115 | |
116 | joiner_xy = [cos_C, sin_C] * b; |
117 | |
118 | for(arm = [0 : arms - 1]) { |
119 | rotate(arm * (360 / arms)) { |
120 | difference() { |
121 | union() { |
122 | translate(bearing_xy) { |
123 | circle(bearing_radius + round_extra); } |
124 | translate(weight_xy) { |
125 | circle(weight_radius + round_extra); } |
126 | mirrored([0, 1]) { |
127 | polygon([bearing_xy, weight_xy, joiner_xy]); } } |
128 | mirrored([0, 1]) { |
129 | translate(joiner_xy) { |
130 | circle(joiner_radius); } } } } } } |
131 | |
132 | module spin_slices(weight_radius, |
133 | weight_thickness, |
134 | bearing_radius, |
135 | bearing_thickness, |
136 | weight_lip_overhang = 0.3, |
137 | bearing_lip_overhang = 0.3, |
138 | wall = 3, |
139 | arms = 3, |
140 | layer_height = 0.15) { |
cc410ed6 |
141 | thicker_thickness = (bearing_thickness > weight_thickness) ? |
142 | bearing_thickness : weight_thickness; |
143 | calculated_height = thicker_thickness + 2 * wall; |
144 | layers = 2 * ceil(ceil(calculated_height / layer_height) / 2); |
145 | actual_height = layers * layer_height; |
146 | round_radius = actual_height / 2; |
147 | |
5f8325d2 |
148 | /* rounding the outside edge of the spinner with a semi-circle leads |
149 | to a shape that an overhang on the second layer several times the |
150 | thickness of a printed extrusion width. |
151 | |
152 | rather than using a full semi-circle, this code aims to use just the |
153 | portion in the middle, where the overhang is less severe */ |
e1a02727 |
154 | old_start = 0; |
155 | old_end = (layers / 2) - 1; |
156 | |
5f8325d2 |
157 | /* add one to have some thickness all around weight holes |
158 | for first layer */ |
5fdbde1b |
159 | new_start = old_end / 16 + 1; |
e1a02727 |
160 | new_end = old_end; |
161 | |
162 | old_range = old_end - old_start; |
163 | new_range = new_end - new_start; |
164 | |
165 | factor = new_range / old_range; |
166 | |
5f8325d2 |
167 | /* initial adjacent is adjusted to (new start - 1) to allow some |
168 | thickness all around weight holes on first layer */ |
169 | initial_adjacent = round_radius - ((new_start - 1) * layer_height); |
e1a02727 |
170 | initial_angle = acos(initial_adjacent / round_radius); |
171 | initial_round_extra = initial_adjacent * tan(initial_angle); |
5f8325d2 |
172 | |
173 | difference() { |
174 | mirrored([0, 0, 1]) { |
175 | for(layer = [0 : (layers / 2) - 1]) { |
176 | translate([0, 0, layer * layer_height - actual_height / 2]) { |
177 | linear_extrude(height = layer_height) { |
178 | new_layer = (layer - old_start) * factor + new_start; |
179 | adjacent = round_radius - (new_layer * layer_height); |
180 | angle = acos(adjacent / round_radius); |
181 | round_extra = adjacent * tan(angle) - initial_round_extra; |
182 | spin_slice(weight_radius, |
183 | bearing_radius, |
184 | round_extra, |
185 | wall, |
186 | arms); } } } } |
187 | cylinder(h = actual_height + 0.1, |
188 | r = bearing_radius - bearing_lip_overhang, |
189 | center = true); |
5fdbde1b |
190 | cylinder(h = bearing_thickness + 0.05, |
191 | r = bearing_radius + 0.15, |
5f8325d2 |
192 | center = true); |
193 | for(arm = [0 : arms - 1]) { |
194 | rotate(arm * (360 / arms)) { |
195 | translate([bearing_radius + wall + weight_radius, 0]) { |
196 | cylinder(h = actual_height + 0.1, |
197 | r = weight_radius - weight_lip_overhang, |
198 | center = true); |
5fdbde1b |
199 | cylinder(h = weight_thickness + 0.05, |
200 | r = weight_radius + 0.15, |
5f8325d2 |
201 | center = true); } } } } } |
818dd661 |
202 | |
1dc634e1 |
203 | module spin_donut(weight_radius, |
204 | weight_thickness, |
205 | bearing_radius, |
206 | bearing_thickness, |
207 | weight_lip_overhang, |
208 | bearing_lip_overhang, |
209 | wall, |
210 | arms) { |
211 | thicker_thickness = (bearing_thickness > weight_thickness) |
212 | ? bearing_thickness : weight_thickness; |
213 | height = thicker_thickness + wall * 2; |
214 | |
215 | center_to_arm_center = bearing_radius + wall + weight_radius; |
216 | |
217 | jelly_filled(height, bearing_radius); |
218 | for(arm = [0 : arms]) { |
219 | rotate(arm * (360 / arms)) { |
220 | translate([center_to_arm_center, 0, 0]) { |
221 | jelly_filled(height, weight_radius); } } } } |
222 | |
818dd661 |
223 | /* |
224 | This file is part of 3d-printables. |
225 | |
226 | 3d-printables is free software: you can redistribute it and/or modify |
227 | it under the terms of the GNU Affero General Public License as published by |
228 | the Free Software Foundation, either version 3 of the License, or |
229 | (at your option) any later version. |
230 | |
231 | 3d-printables is distributed in the hope that it will be useful, |
232 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
233 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
234 | GNU Affero General Public License for more details. |
235 | |
236 | You should have received a copy of the GNU Affero General Public License |
237 | along with challenge-bot. If not, see <http://www.gnu.org/licenses/>. |
238 | */ |