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