818dd661 |
1 | /* GNU AGPLv3 (or later at your option) |
2 | see bottom for more license info */ |
3 | |
4 | /* spin thing that erin likes */ |
3e3691aa |
5 | $fn = 500; |
818dd661 |
6 | |
7 | weight = "penny"; |
8 | // weight = "608zz"; |
3e3691aa |
9 | bearing = "608zz"; |
2645ef26 |
10 | weight_lip_thickness = 1; |
818dd661 |
11 | wall_thickness = 2; |
2645ef26 |
12 | penny_thickness = 1.52; |
818dd661 |
13 | penny_radius = 19.05 / 2; |
7f1519fb |
14 | |
15 | _608zz_radius = 22 / 2; |
16 | _608zz_inner_radius = 8.1 / 2; |
17 | _608zz_cover_radius = 19.4 / 2; |
18 | _608zz_cap_footprint_radius = 12 / 2; |
19 | _608zz_thickness = 7; |
20 | |
818dd661 |
21 | weight_radius = (weight == "penny") ? penny_radius : _608zz_radius; |
2645ef26 |
22 | weight_thickness = (weight == "penny") ? |
23 | penny_thickness * 5 : _608zz_thickness; |
7f1519fb |
24 | |
3e3691aa |
25 | bearing_radius = (bearing == "608zz") ? _608zz_radius : 1/0; |
7f1519fb |
26 | bearing_inner_radius = (bearing == "608zz") ? _608zz_inner_radius : 1/0; |
27 | bearing_cover_radius = (bearing == "608zz") |
28 | ? _608zz_cover_radius + wall_thickness |
29 | : 1/0; |
30 | bearing_cap_footprint_radius = |
31 | (bearing == "608zz") ? _608zz_cap_footprint_radius : 1/0; |
2645ef26 |
32 | bearing_thickness = (bearing == "608zz") ? _608zz_thickness : 1/0; |
7f1519fb |
33 | |
34 | spinner_height = penny_thickness * 5 + 2; |
818dd661 |
35 | arms = 3; |
36 | |
7f1519fb |
37 | module cap(bearing_inner_radius, |
38 | bearing_cap_footprint_radius, |
39 | bearing_cover_radius, |
40 | bearing_thickness) { |
41 | footprint_height = 1.6; |
42 | footprint_radius_safety = 0.25; |
43 | cap_height = 3; |
44 | bearing_cover_radius_safety = 0.75; |
45 | bearing_thickness_safety = 0.2; |
46 | |
47 | difference() { |
48 | union() { |
49 | cylinder(r1 = bearing_cover_radius - tan(30) * cap_height, |
50 | r2 = bearing_cover_radius, |
51 | h = cap_height); |
52 | linear_extrude(height = cap_height + footprint_height) { |
53 | circle(bearing_cap_footprint_radius - footprint_radius_safety); } |
54 | linear_extrude(height = cap_height |
55 | + footprint_height |
56 | + bearing_thickness / 2 |
57 | - bearing_thickness_safety) { |
58 | circle(bearing_inner_radius); } } |
59 | translate([0, 0, -0.01]) { |
60 | cylinder(r1 = bearing_inner_radius + tan(30) * (cap_height - 1), |
61 | r2 = bearing_inner_radius, |
62 | h = cap_height - 1); } } } |
63 | |
2645ef26 |
64 | module ring(outer_radius, inner_radius) { |
65 | difference() { |
66 | circle(outer_radius); |
67 | circle(inner_radius); } } |
68 | |
69 | module spin_2d(weight_radius, |
70 | arms, |
71 | wall_thickness, |
72 | bearing_radius) { |
3e3691aa |
73 | bearing_holder_radius = bearing_radius + wall_thickness; |
818dd661 |
74 | weight_holder_radius = weight_radius + wall_thickness; |
3e3691aa |
75 | |
2645ef26 |
76 | ring(bearing_holder_radius, bearing_radius); |
3e3691aa |
77 | |
78 | /* |
2645ef26 |
79 | * imagine a triangle with one point at the origin, at the |
3e3691aa |
80 | * center of the spinning bearing holder, one point in the middle of |
81 | * the weight holder, and one point at the center of a circle tangent |
82 | * to the first two, called the joiner circle. |
83 | * the radius of the joiner circle is the arithmetic average of the |
84 | * weight holder and bearing holder. |
85 | */ |
86 | joiner_radius = (bearing_holder_radius + weight_holder_radius) / 2; |
87 | /* a: goes between the center of the weight holder and the center of |
88 | the joiner circle. */ |
89 | a = joiner_radius + weight_holder_radius; |
90 | /* b: length of the base, which goes along the x-axis between |
91 | the origin and the center of the weight holder. */ |
92 | b = weight_holder_radius + bearing_holder_radius; |
93 | /* c: goes between origin and joiner circle. */ |
94 | c = bearing_holder_radius + joiner_radius; |
95 | |
2645ef26 |
96 | /* A: angle at the origin, between the base and segment from origin |
97 | to center of joiner circle. |
3e3691aa |
98 | it is calculated using law of cosines, given the lengths of |
99 | all 3 sides of the triangle. */ |
100 | A = acos((pow(b, 2) + pow(c, 2) - pow(a, 2)) / (2 * b * c)); |
101 | /* find the center of the joiner circle */ |
102 | joiner_x = cos(A) * c; |
103 | joiner_y = sin(A) * c; |
104 | |
105 | /* find the points where the circles meet */ |
106 | bearing_joiner_point = [cos(A) * bearing_holder_radius, |
107 | sin(A) * bearing_holder_radius]; |
108 | bearing_weight_point = [bearing_holder_radius, 0]; |
109 | /* C: angle between x-axis and line-segment between center of weight |
110 | holder and center of joiner. |
111 | it is calculated using law of cosines, given the lengths of |
112 | all 3 sides of the triangle. */ |
113 | C = acos((pow(a, 2) + pow(b, 2) - pow(c, 2)) / (2 * a * b)); |
114 | weight_joiner_point = [b - cos(C) * weight_holder_radius, |
115 | sin(C) * weight_holder_radius]; |
818dd661 |
116 | for(arm = [0 : arms - 1]) { |
117 | rotate(arm * 360.0 / arms) { |
3e3691aa |
118 | difference() { |
119 | polygon([bearing_weight_point, |
120 | bearing_joiner_point, |
121 | weight_joiner_point]); |
122 | translate([joiner_x, joiner_y]) { |
2645ef26 |
123 | circle(joiner_radius); } |
124 | translate([weight_holder_radius + bearing_holder_radius, 0]) { |
125 | circle(weight_holder_radius); } } |
3e3691aa |
126 | mirror(v = [0, 1, 0]) { |
127 | difference() { |
128 | polygon([bearing_weight_point, |
129 | bearing_joiner_point, |
130 | weight_joiner_point]); |
131 | translate([joiner_x, joiner_y]) { |
2645ef26 |
132 | circle(joiner_radius); } |
133 | translate([weight_holder_radius + bearing_holder_radius, 0]) { |
134 | circle(weight_holder_radius); } } } |
3e3691aa |
135 | translate([weight_holder_radius + bearing_holder_radius, 0]) { |
2645ef26 |
136 | ring(weight_holder_radius, weight_radius); } } } } |
137 | |
138 | module spin(weight_radius, |
139 | weight_thickness, |
140 | weight_lip_thickness, |
141 | arms, |
142 | wall_thickness, |
143 | bearing_radius, |
7f1519fb |
144 | bearing_thickness) { |
2645ef26 |
145 | /* TODO: make window size parameter */ |
146 | /* TODO: rethink how lips are done */ |
147 | /* TODO: right now, weight is assumed to be thicker than bearing*/ |
7f1519fb |
148 | spinner_height = weight_thickness + 2 * weight_lip_thickness; |
2645ef26 |
149 | bearing_lip_thickness = (spinner_height - bearing_thickness) / 2; |
150 | linear_extrude(height = weight_lip_thickness) { |
151 | spin_2d(weight_radius - 1, |
152 | arms, |
153 | wall_thickness + 1, |
154 | bearing_radius - 1); } |
155 | linear_extrude(height = bearing_lip_thickness) { |
156 | ring(bearing_radius, bearing_radius - 1); } |
157 | linear_extrude(height = spinner_height) { |
158 | spin_2d(weight_radius, arms, wall_thickness, bearing_radius); } |
159 | translate([0, 0, spinner_height - bearing_lip_thickness]) { |
160 | linear_extrude(height = bearing_lip_thickness) { |
161 | ring(bearing_radius, bearing_radius - 1); } } |
162 | translate([0, 0, spinner_height - weight_lip_thickness]) { |
163 | linear_extrude(height = weight_lip_thickness) { |
164 | spin_2d(weight_radius - 1, |
165 | arms, |
166 | wall_thickness + 1, |
167 | bearing_radius - 1); } } } |
818dd661 |
168 | |
169 | /* |
170 | This file is part of 3d-printables. |
171 | |
172 | 3d-printables is free software: you can redistribute it and/or modify |
173 | it under the terms of the GNU Affero General Public License as published by |
174 | the Free Software Foundation, either version 3 of the License, or |
175 | (at your option) any later version. |
176 | |
177 | 3d-printables is distributed in the hope that it will be useful, |
178 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
179 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
180 | GNU Affero General Public License for more details. |
181 | |
182 | You should have received a copy of the GNU Affero General Public License |
183 | along with challenge-bot. If not, see <http://www.gnu.org/licenses/>. |
184 | */ |