give lip to hold in penny and bearing
[ozzloy@gmail.com/3d-printables] / spin-data.scad
CommitLineData
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
7weight = "penny";
8// weight = "608zz";
3e3691aa 9bearing = "608zz";
2645ef26 10weight_lip_thickness = 1;
818dd661 11wall_thickness = 2;
2645ef26 12penny_thickness = 1.52;
13spinner_height = penny_thickness * 5 + 2;
818dd661 14_608zz_radius = 22;
2645ef26 15_608zz_thickness = 7;
818dd661 16penny_radius = 19.05 / 2;
818dd661 17weight_radius = (weight == "penny") ? penny_radius : _608zz_radius;
2645ef26 18weight_thickness = (weight == "penny") ?
19 penny_thickness * 5 : _608zz_thickness;
3e3691aa 20bearing_radius = (bearing == "608zz") ? _608zz_radius : 1/0;
2645ef26 21bearing_thickness = (bearing == "608zz") ? _608zz_thickness : 1/0;
818dd661 22arms = 3;
23
2645ef26 24module ring(outer_radius, inner_radius) {
25 difference() {
26 circle(outer_radius);
27 circle(inner_radius); } }
28
29module spin_2d(weight_radius,
30 arms,
31 wall_thickness,
32 bearing_radius) {
3e3691aa 33 bearing_holder_radius = bearing_radius + wall_thickness;
818dd661 34 weight_holder_radius = weight_radius + wall_thickness;
3e3691aa 35
2645ef26 36 ring(bearing_holder_radius, bearing_radius);
3e3691aa 37
38 /*
2645ef26 39 * imagine a triangle with one point at the origin, at the
3e3691aa 40 * center of the spinning bearing holder, one point in the middle of
41 * the weight holder, and one point at the center of a circle tangent
42 * to the first two, called the joiner circle.
43 * the radius of the joiner circle is the arithmetic average of the
44 * weight holder and bearing holder.
45 */
46 joiner_radius = (bearing_holder_radius + weight_holder_radius) / 2;
47 /* a: goes between the center of the weight holder and the center of
48 the joiner circle. */
49 a = joiner_radius + weight_holder_radius;
50 /* b: length of the base, which goes along the x-axis between
51 the origin and the center of the weight holder. */
52 b = weight_holder_radius + bearing_holder_radius;
53 /* c: goes between origin and joiner circle. */
54 c = bearing_holder_radius + joiner_radius;
55
2645ef26 56 /* A: angle at the origin, between the base and segment from origin
57 to center of joiner circle.
3e3691aa 58 it is calculated using law of cosines, given the lengths of
59 all 3 sides of the triangle. */
60 A = acos((pow(b, 2) + pow(c, 2) - pow(a, 2)) / (2 * b * c));
61 /* find the center of the joiner circle */
62 joiner_x = cos(A) * c;
63 joiner_y = sin(A) * c;
64
65 /* find the points where the circles meet */
66 bearing_joiner_point = [cos(A) * bearing_holder_radius,
67 sin(A) * bearing_holder_radius];
68 bearing_weight_point = [bearing_holder_radius, 0];
69 /* C: angle between x-axis and line-segment between center of weight
70 holder and center of joiner.
71 it is calculated using law of cosines, given the lengths of
72 all 3 sides of the triangle. */
73 C = acos((pow(a, 2) + pow(b, 2) - pow(c, 2)) / (2 * a * b));
74 weight_joiner_point = [b - cos(C) * weight_holder_radius,
75 sin(C) * weight_holder_radius];
818dd661 76 for(arm = [0 : arms - 1]) {
77 rotate(arm * 360.0 / arms) {
3e3691aa 78 difference() {
79 polygon([bearing_weight_point,
80 bearing_joiner_point,
81 weight_joiner_point]);
82 translate([joiner_x, joiner_y]) {
2645ef26 83 circle(joiner_radius); }
84 translate([weight_holder_radius + bearing_holder_radius, 0]) {
85 circle(weight_holder_radius); } }
3e3691aa 86 mirror(v = [0, 1, 0]) {
87 difference() {
88 polygon([bearing_weight_point,
89 bearing_joiner_point,
90 weight_joiner_point]);
91 translate([joiner_x, joiner_y]) {
2645ef26 92 circle(joiner_radius); }
93 translate([weight_holder_radius + bearing_holder_radius, 0]) {
94 circle(weight_holder_radius); } } }
3e3691aa 95 translate([weight_holder_radius + bearing_holder_radius, 0]) {
2645ef26 96 ring(weight_holder_radius, weight_radius); } } } }
97
98module spin(weight_radius,
99 weight_thickness,
100 weight_lip_thickness,
101 arms,
102 wall_thickness,
103 bearing_radius,
104 bearing_thickness,
105 spinner_height) {
106 /* TODO: make window size parameter */
107 /* TODO: rethink how lips are done */
108 /* TODO: right now, weight is assumed to be thicker than bearing*/
109 bearing_lip_thickness = (spinner_height - bearing_thickness) / 2;
110 linear_extrude(height = weight_lip_thickness) {
111 spin_2d(weight_radius - 1,
112 arms,
113 wall_thickness + 1,
114 bearing_radius - 1); }
115 linear_extrude(height = bearing_lip_thickness) {
116 ring(bearing_radius, bearing_radius - 1); }
117 linear_extrude(height = spinner_height) {
118 spin_2d(weight_radius, arms, wall_thickness, bearing_radius); }
119 translate([0, 0, spinner_height - bearing_lip_thickness]) {
120 linear_extrude(height = bearing_lip_thickness) {
121 ring(bearing_radius, bearing_radius - 1); } }
122 translate([0, 0, spinner_height - weight_lip_thickness]) {
123 linear_extrude(height = weight_lip_thickness) {
124 spin_2d(weight_radius - 1,
125 arms,
126 wall_thickness + 1,
127 bearing_radius - 1); } } }
818dd661 128
129/*
130 This file is part of 3d-printables.
131
132 3d-printables is free software: you can redistribute it and/or modify
133 it under the terms of the GNU Affero General Public License as published by
134 the Free Software Foundation, either version 3 of the License, or
135 (at your option) any later version.
136
137 3d-printables is distributed in the hope that it will be useful,
138 but WITHOUT ANY WARRANTY; without even the implied warranty of
139 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
140 GNU Affero General Public License for more details.
141
142 You should have received a copy of the GNU Affero General Public License
143 along with challenge-bot. If not, see <http://www.gnu.org/licenses/>.
144*/