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"; |
818dd661 |
10 | wall_thickness = 2; |
11 | _608zz_radius = 22; |
12 | penny_radius = 19.05 / 2; |
13 | penny_thickness = 1.52; |
14 | weight_radius = (weight == "penny") ? penny_radius : _608zz_radius; |
3e3691aa |
15 | bearing_radius = (bearing == "608zz") ? _608zz_radius : 1/0; |
818dd661 |
16 | arms = 3; |
17 | |
3e3691aa |
18 | module spin(weight_radius, |
19 | arms, |
20 | wall_thickness, |
21 | bearing_radius) { |
22 | bearing_holder_radius = bearing_radius + wall_thickness; |
818dd661 |
23 | weight_holder_radius = weight_radius + wall_thickness; |
3e3691aa |
24 | |
25 | circle(bearing_holder_radius); |
26 | |
27 | /* |
28 | * imagine a right triangle with one point at the origin, at the |
29 | * center of the spinning bearing holder, one point in the middle of |
30 | * the weight holder, and one point at the center of a circle tangent |
31 | * to the first two, called the joiner circle. |
32 | * the radius of the joiner circle is the arithmetic average of the |
33 | * weight holder and bearing holder. |
34 | */ |
35 | joiner_radius = (bearing_holder_radius + weight_holder_radius) / 2; |
36 | /* a: goes between the center of the weight holder and the center of |
37 | the joiner circle. */ |
38 | a = joiner_radius + weight_holder_radius; |
39 | /* b: length of the base, which goes along the x-axis between |
40 | the origin and the center of the weight holder. */ |
41 | b = weight_holder_radius + bearing_holder_radius; |
42 | /* c: goes between origin and joiner circle. */ |
43 | c = bearing_holder_radius + joiner_radius; |
44 | |
45 | /* A: angle at the origin, between the base and hypotenuse. |
46 | it is calculated using law of cosines, given the lengths of |
47 | all 3 sides of the triangle. */ |
48 | A = acos((pow(b, 2) + pow(c, 2) - pow(a, 2)) / (2 * b * c)); |
49 | /* find the center of the joiner circle */ |
50 | joiner_x = cos(A) * c; |
51 | joiner_y = sin(A) * c; |
52 | |
53 | /* find the points where the circles meet */ |
54 | bearing_joiner_point = [cos(A) * bearing_holder_radius, |
55 | sin(A) * bearing_holder_radius]; |
56 | bearing_weight_point = [bearing_holder_radius, 0]; |
57 | /* C: angle between x-axis and line-segment between center of weight |
58 | holder and center of joiner. |
59 | it is calculated using law of cosines, given the lengths of |
60 | all 3 sides of the triangle. */ |
61 | C = acos((pow(a, 2) + pow(b, 2) - pow(c, 2)) / (2 * a * b)); |
62 | weight_joiner_point = [b - cos(C) * weight_holder_radius, |
63 | sin(C) * weight_holder_radius]; |
818dd661 |
64 | for(arm = [0 : arms - 1]) { |
65 | rotate(arm * 360.0 / arms) { |
3e3691aa |
66 | difference() { |
67 | polygon([bearing_weight_point, |
68 | bearing_joiner_point, |
69 | weight_joiner_point]); |
70 | translate([joiner_x, joiner_y]) { |
71 | circle(joiner_radius); } } |
72 | mirror(v = [0, 1, 0]) { |
73 | difference() { |
74 | polygon([bearing_weight_point, |
75 | bearing_joiner_point, |
76 | weight_joiner_point]); |
77 | translate([joiner_x, joiner_y]) { |
78 | circle(joiner_radius); } } } |
79 | translate([weight_holder_radius + bearing_holder_radius, 0]) { |
818dd661 |
80 | circle(weight_holder_radius); } } } } |
81 | |
82 | /* |
83 | This file is part of 3d-printables. |
84 | |
85 | 3d-printables is free software: you can redistribute it and/or modify |
86 | it under the terms of the GNU Affero General Public License as published by |
87 | the Free Software Foundation, either version 3 of the License, or |
88 | (at your option) any later version. |
89 | |
90 | 3d-printables is distributed in the hope that it will be useful, |
91 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
92 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
93 | GNU Affero General Public License for more details. |
94 | |
95 | You should have received a copy of the GNU Affero General Public License |
96 | along with challenge-bot. If not, see <http://www.gnu.org/licenses/>. |
97 | */ |