summaryrefslogtreecommitdiff
path: root/another.scad
authorMichael Krelin <hacker@klever.net>2018-08-02 11:23:57 (UTC)
committer Michael Krelin <hacker@klever.net>2018-08-02 11:23:57 (UTC)
commit290784caf892a0bbea84332ff4ae6767b0fcddd1 (patch) (unidiff)
tree1e167203f6a8227ae3f868471032b7127274f9d2 /another.scad
parent62df5d5cfcaa6ede9f3b6441de8a0a3a963d9d97 (diff)
downloadextrudery-290784caf892a0bbea84332ff4ae6767b0fcddd1.zip
extrudery-290784caf892a0bbea84332ff4ae6767b0fcddd1.tar.gz
extrudery-290784caf892a0bbea84332ff4ae6767b0fcddd1.tar.bz2
another: adjust and prettify $fn calculations
Diffstat (limited to 'another.scad') (more/less context) (ignore whitespace changes)
-rw-r--r--another.scad61
1 files changed, 31 insertions, 30 deletions
diff --git a/another.scad b/another.scad
index 302e314..872ff33 100644
--- a/another.scad
+++ b/another.scad
@@ -58,12 +58,14 @@ module the_extruder(
58 left=false, 58 left=false,
59 vitamins = true, 59 vitamins = true,
60 supports = false, 60 supports = false,
61 tensioner = true, 61 tensioner = true,
62 debug = false 62 debug = false
63) { 63) {
64 fnd = 2*PI; fnr = 2*fnd;
65
64 lever_shell = mount_screwhead_h+0.5; 66 lever_shell = mount_screwhead_h+0.5;
65 lever_thickness=max(spring_d+spring_d_clearance+layer_height*8,idler_h+idler_v_tolerance+2*lever_shell); 67 lever_thickness=max(spring_d+spring_d_clearance+layer_height*8,idler_h+idler_v_tolerance+2*lever_shell);
66 lsd = idler_d-idler_clearance*2; 68 lsd = idler_d-idler_clearance*2;
67 longwing=gearbox_d/2+spring_d/2+lsd/2; 69 longwing=gearbox_d/2+spring_d/2+lsd/2;
68 h_ = (pulley_d+idler_d)/(2*sqrt(2)); 70 h_ = (pulley_d+idler_d)/(2*sqrt(2));
69 ri = sqrt( pow(h_,2) + pow(mount_d/2-h_,2) ); 71 ri = sqrt( pow(h_,2) + pow(mount_d/2-h_,2) );
@@ -83,16 +85,16 @@ module the_extruder(
83 children(); 85 children();
84 } 86 }
85 module finger_indent(d=lever_thickness,depth/*=1*/,r/*=15*/) { 87 module finger_indent(d=lever_thickness,depth/*=1*/,r/*=15*/) {
86 if(depth) { 88 if(depth) {
87 hh = (-4*pow(depth,2)+pow(d,2))/(8*depth); 89 hh = (-4*pow(depth,2)+pow(d,2))/(8*depth);
88 rr = depth+hh; 90 rr = depth+hh;
89 translate([0,0,hh]) sphere(r=rr,$fn=2*PI*rr); 91 translate([0,0,hh]) sphere(r=rr,$fn=fnr*rr);
90 }else if(r) { 92 }else if(r) {
91 hh=sqrt(pow(r,2)-pow(d,2)/4); 93 hh=sqrt(pow(r,2)-pow(d,2)/4);
92 translate([0,0,hh]) sphere(r=r,$fn=2*PI*r); 94 translate([0,0,hh]) sphere(r=r,$fn=fnr*r);
93 } 95 }
94 } 96 }
95 97
96 % if(vitamins) mirrorleft() { 98 % if(vitamins) mirrorleft() {
97 translate([0,0,-epsilon]) mirror([0,0,1]) cylinder(d=gearbox_d,h=1,$fn=60); 99 translate([0,0,-epsilon]) mirror([0,0,1]) cylinder(d=gearbox_d,h=1,$fn=60);
98 for(zr=[0:90:359]) rotate([0,0,zr]) translate([mount_d/2,0,0]) 100 for(zr=[0:90:359]) rotate([0,0,zr]) translate([mount_d/2,0,0])
@@ -155,26 +157,26 @@ module the_extruder(
155 if(supports) for(y=[-lsd/2+extrusion_width:(lsd-2*extrusion_width)/3:lsd/2-extrusion_width]) 157 if(supports) for(y=[-lsd/2+extrusion_width:(lsd-2*extrusion_width)/3:lsd/2-extrusion_width])
156 translate([-lsd/2-1,y-extrusion_width/2,-idler_h/2-idler_v_tolerance/2-1]) 158 translate([-lsd/2-1,y-extrusion_width/2,-idler_h/2-idler_v_tolerance/2-1])
157 cube(size=[lsd+2,extrusion_width,idler_h+idler_v_tolerance+2]); 159 cube(size=[lsd+2,extrusion_width,idler_h+idler_v_tolerance+2]);
158 } 160 }
159 cylinder(d=mount_screw_d+mount_screw_d_tolerance,h=lever_thickness+2,center=true,$fn=30); 161 cylinder(d=mount_screw_d+mount_screw_d_tolerance,h=lever_thickness+2,center=true,$fn=30);
160 translate([0,0,lever_thickness/2-mount_screwhead_h]) 162 translate([0,0,lever_thickness/2-mount_screwhead_h])
161 cylinder(d=mount_screwhead_d,h=mount_screwhead_h+1,$fn=2*PI*mount_screwhead_d); 163 cylinder(d=mount_screwhead_d,h=mount_screwhead_h+1,$fn=fnd*mount_screwhead_d);
162 } 164 }
163 // mounting screw hole 165 // mounting screw hole
164 translate([mount_d/2,0,0]) 166 translate([mount_d/2,0,0])
165 cylinder(d=mount_screw_d+mount_screw_d_tolerance,h=lever_thickness+2,center=true,$fn=2*PI*mount_screw_d); 167 cylinder(d=mount_screw_d+mount_screw_d_tolerance,h=lever_thickness+2,center=true,$fn=fnd*mount_screw_d);
166 168
167 // lever end 169 // lever end
168 translate([mount_d/2,0,0]) rotate([0,90,0]) { 170 translate([mount_d/2,0,0]) rotate([0,90,0]) {
169 translate([0,-longwing,lsd/2]) finger_indent(d=lever_thickness-1,r=15); 171 translate([0,-longwing,lsd/2]) finger_indent(d=lever_thickness-1,r=15);
170 translate([0,-longwing,0]) 172 translate([0,-longwing,0])
171 mirror([0,0,1]) 173 mirror([0,0,1])
172 difference() { 174 difference() {
173 cylinder(d=spring_d+spring_d_clearance,h=lsd,$fn=2*PI*spring_d); 175 cylinder(d=spring_d+spring_d_clearance,h=lsd,$fn=fnd*(spring_d+spring_d_clearance));
174 sphere(d=spring_d*3/4,$fn=PI*spring_d); 176 sphere(d=spring_d*3/4,$fn=fnd*spring_d*3/4);
175 } 177 }
176 }//rotate-translate 178 }//rotate-translate
177 }//difference 179 }//difference
178 // bridging patch 180 // bridging patch
179 place_idler() 181 place_idler()
180 translate([0,0,lever_thickness/2-mount_screwhead_h]) 182 translate([0,0,lever_thickness/2-mount_screwhead_h])
@@ -183,21 +185,21 @@ module the_extruder(
183 }//translate 185 }//translate
184 }//lever module 186 }//lever module
185 187
186 module body() { 188 module body() {
187 difference() { 189 difference() {
188 union() { 190 union() {
189 cylinder(d=gearbox_d,h=body_h,$fn=2*PI*gearbox_d); 191 cylinder(d=gearbox_d,h=body_h,$fn=fnd*gearbox_d);
190 // finger and spring support 192 // finger and spring support
191 fsw = gearbox_d/2+mount_screwhead_d/2; 193 fsw = gearbox_d/2+mount_screwhead_d/2;
192 translate([-gearbox_d/2,0,0]) difference() { 194 translate([-gearbox_d/2,0,0]) difference() {
193 union() { 195 union() {
194 hull() { 196 hull() {
195 translate([0,-longwing,ls_z]) 197 translate([0,-longwing,ls_z])
196 rotate([0,90,0]) 198 rotate([0,90,0])
197 cylinder(d=max(lever_thickness,spring_d+spring_d_clearance+2*extrusion_width),h=fsw,$fn=2*PI*lever_thickness); 199 cylinder(d=lever_thickness,h=fsw,$fn=fnd*lever_thickness);
198 hh=body_h-ls_z; 200 hh=body_h-ls_z;
199 translate([0,0,ls_z-lever_thickness/2]) 201 translate([0,0,ls_z-lever_thickness/2])
200 mirror([0,1,0]) cube(size=[fsw,longwing-hh+lever_thickness/sqrt(2),hh+lever_thickness/2]); 202 mirror([0,1,0]) cube(size=[fsw,longwing-hh+lever_thickness/sqrt(2),hh+lever_thickness/2]);
201 hhh=ls_z; 203 hhh=ls_z;
202 translate([0,0,0]) 204 translate([0,0,0])
203 mirror([0,1,0]) cube(size=[fsw,longwing-hhh+lever_thickness/sqrt(2),hhh+lever_thickness/2]); 205 mirror([0,1,0]) cube(size=[fsw,longwing-hhh+lever_thickness/sqrt(2),hhh+lever_thickness/2]);
@@ -208,20 +210,20 @@ module the_extruder(
208 if(debug) translate([0,-gearbox_d,-gearbox_d]) cube(size=[body_h/2+1,gearbox_d,gearbox_d+2]); 210 if(debug) translate([0,-gearbox_d,-gearbox_d]) cube(size=[body_h/2+1,gearbox_d,gearbox_d+2]);
209 mirror([0,0,1]) { 211 mirror([0,0,1]) {
210 translate([0,0,st_shell]) 212 translate([0,0,st_shell])
211 hull() for(o=[0,spring_d]) translate([0,-o,0]) 213 hull() for(o=[0,spring_d]) translate([0,-o,0])
212 rotate([0,0,30]) 214 rotate([0,0,30])
213 cylinder(d=st_nut_d,h=st_nut_h,$fn=6); 215 cylinder(d=st_nut_d,h=st_nut_h,$fn=6);
214 translate([0,0,-1]) cylinder(d=st_screw_d,h=fsw+2,$fn=st_screw_d*PI*2); 216 translate([0,0,-1]) cylinder(d=st_screw_d,h=fsw+2,$fn=fnd*st_screw_d);
215 bigd = spring_d+spring_d_clearance; 217 bigd = spring_d+spring_d_clearance;
216 hf = (bigd-st_screw_d)/2; 218 hf = (bigd-st_screw_d)/2;
217 translate([0,0,st_shell+st_nut_h+st_shell-epsilon]) 219 translate([0,0,st_shell+st_nut_h+st_shell-epsilon])
218 cylinder(d1=st_screw_d,d2=bigd, 220 cylinder(d1=st_screw_d,d2=bigd,
219 h=hf+epsilon, $fn=bigd*PI*2 ); 221 h=hf+epsilon, $fn=fnd*bigd);
220 translate([0,0,st_shell+st_nut_h+st_shell+hf-epsilon]) 222 translate([0,0,st_shell+st_nut_h+st_shell+hf-epsilon])
221 cylinder(d=bigd,h=fsw+1,$fn=bigd*PI*2); 223 cylinder(d=bigd,h=fsw+1,$fn=fnd*bigd);
222 } 224 }
223 } 225 }
224 } 226 }
225 } // translate 227 } // translate
226 228
227 // pushfit bracket 229 // pushfit bracket
@@ -230,42 +232,42 @@ module the_extruder(
230 rotate([-90,0,0]) 232 rotate([-90,0,0])
231 translate([0,0,mount_d/sqrt(2)/2+mount_screw_d-gearbox_d/2/*TODO:*/]) 233 translate([0,0,mount_d/sqrt(2)/2+mount_screw_d-gearbox_d/2/*TODO:*/])
232 cylinder(r=min(body_h-filament_elevation,filament_elevation)/sin(60)-epsilon,h=pf_h(pf)+gearbox_d/2/*TODO:*/,$fn=6); 234 cylinder(r=min(body_h-filament_elevation,filament_elevation)/sin(60)-epsilon,h=pf_h(pf)+gearbox_d/2/*TODO:*/,$fn=6);
233 }//union (first child of difference) 235 }//union (first child of difference)
234 // protrusion 236 // protrusion
235 translate([0,0,-1]) 237 translate([0,0,-1])
236 cylinder(d=protrusion_d+protrusion_tolerance_h,h=protrusion_h+protrusion_tolerance_v+1,$fn=2*PI*protrusion_d); 238 cylinder(d=protrusion_d+protrusion_tolerance_h,h=protrusion_h+protrusion_tolerance_v+1,$fn=fnd*(protrusion_d+protrusion_tolerance_h));
237 // mount screw holes 239 // mount screw holes
238 for(zr=[0:90:359]) rotate([0,0,zr]) translate([mount_d/2,0,0]) { 240 for(zr=[0:90:359]) rotate([0,0,zr]) translate([mount_d/2,0,0]) {
239 translate([0,0,mount_screw_l-mounthole_depth/2-layer_height-1]) 241 translate([0,0,mount_screw_l-mounthole_depth/2-layer_height-1])
240 mirror([0,0,1]) 242 mirror([0,0,1])
241 cylinder(d=mount_screw_d+mount_screw_d_tolerance, 243 cylinder(d=mount_screw_d+mount_screw_d_tolerance,
242 h=mount_screw_l-mounthole_depth/2-layer_height+1, 244 h=mount_screw_l-mounthole_depth/2-layer_height+1,
243 $fn=2*PI*mount_screw_d); 245 $fn=fnd*(mount_screw_d+mount_screw_d_tolerance));
244 translate([0,0,mount_screw_l-mounthole_depth/2]) 246 translate([0,0,mount_screw_l-mounthole_depth/2])
245 cylinder(d=mount_screwhead_d,h=body_h+1,$fn=2*PI*mount_screwhead_d); 247 cylinder(d=mount_screwhead_d,h=body_h+1,$fn=fnd*mount_screwhead_d);
246 }//for 248 }//for
247 // pushfit 249 // pushfit
248 translate([0,0,filament_elevation]) 250 translate([0,0,filament_elevation])
249 rotate([0,0,45]) translate([pulley_d/2,0,0]) 251 rotate([0,0,45]) translate([pulley_d/2,0,0])
250 rotate([-90,0,0]) 252 rotate([-90,0,0])
251 translate([0,0,mount_d/sqrt(2)/2+mount_screw_d+epsilon]) 253 translate([0,0,mount_d/sqrt(2)/2+mount_screw_d+epsilon])
252 rotate([0,0,180]) { 254 rotate([0,0,180]) {
253 pushfit(pf); 255 pushfit(pf);
254 cylinder(d=filament_guide_d,h=gearbox_d,center=true,$fn=2*PI*filament_guide_d); 256 cylinder(d=filament_guide_d,h=gearbox_d,center=true,$fn=fnd*filament_guide_d);
255 translate([0,-filament_guide_d/2/sqrt(2),0]) 257 translate([0,-filament_guide_d/2/sqrt(2),0])
256 rotate([0,0,45]) 258 rotate([0,0,45])
257 cube(size=[filament_guide_d/2,filament_guide_d/2,gearbox_d],center=true); 259 cube(size=[filament_guide_d/2,filament_guide_d/2,gearbox_d],center=true);
258 } 260 }
259 // pulley 261 // pulley
260 cylinder(d=pulley_d+pulley_clearance,h=body_h+1,$fn=2*PI*(pulley_d+pulley_clearance)); 262 cylinder(d=pulley_d+pulley_clearance,h=body_h+1,$fn=fnd*(pulley_d+pulley_clearance));
261 // leverspace 263 // leverspace
262 hull() for(x=[0,gearbox_d]) 264 hull() for(x=[0,gearbox_d])
263 rotate([0,0,45]) 265 rotate([0,0,45])
264 translate([x,0,ls_z-ls_h/2]) 266 translate([x,0,ls_z-ls_h/2])
265 cylinder(d=idler_d+idler_clearance,h=ls_h,$fn=2*PI*idler_d); 267 cylinder(d=idler_d+idler_clearance,h=ls_h,$fn=fnd*(idler_d+idler_clearance));
266 268
267 a=cos(45)*(pulley_d+idler_d)/2; 269 a=cos(45)*(pulley_d+idler_d)/2;
268 b=mount_d/2-a; 270 b=mount_d/2-a;
269 x=sqrt(pow(a,2)+pow(b,2)); 271 x=sqrt(pow(a,2)+pow(b,2));
270 translate([mount_d/2,0,ls_z]) 272 translate([mount_d/2,0,ls_z])
271 intersection() { 273 intersection() {
@@ -282,24 +284,23 @@ module the_extruder(
282 mirror([0,1,0]) 284 mirror([0,1,0])
283 cube(size=[gearbox_d,gearbox_d/2+1,lever_thickness+lever_v_clearance]); 285 cube(size=[gearbox_d,gearbox_d/2+1,lever_thickness+lever_v_clearance]);
284 } 286 }
285 //translate([-mount_d/2,-longwing,filament_elevation]) 287 //translate([-mount_d/2,-longwing,filament_elevation])
286 if(!tensioner) translate([mount_d/2,-longwing,filament_elevation]) 288 if(!tensioner) translate([mount_d/2,-longwing,filament_elevation])
287 rotate([0,-90,0]) difference() { 289 rotate([0,-90,0]) difference() {
288 cylinder(d=spring_d+spring_d_clearance,h=spring_lc+spring_dl,$fn=PI*spring_d); 290 cylinder(d=spring_d+spring_d_clearance,h=spring_lc+spring_dl,$fn=fnd*(spring_d+spring_d_clearance));
289 translate([0,0,spring_lc+spring_dl]) sphere(d=spring_d*3/4,$fn=PI*spring_d); 291 translate([0,0,spring_lc+spring_dl]) sphere(d=spring_d*3/4,$fn=fnd*spring_d*3/4);
290 }
291 } 292 }
292 293
293 }//difference 294 }//difference
294 295
295 if(supports) intersection() { 296 if(supports) intersection() {
296 difference() { 297 difference() {
297 translate([0,0,ls_z-ls_h/2-epsilon]) 298 translate([0,0,ls_z-ls_h/2-epsilon])
298 cylinder(d=gearbox_d,h=ls_h+2*epsilon,$fn=2*PI*gearbox_d); 299 cylinder(d=gearbox_d,h=ls_h+2*epsilon,$fn=fnd*gearbox_d);
299 cylinder(d=pulley_d+pulley_clearance,h=body_h+1,$fn=2*PI*(pulley_d+pulley_clearance)); 300 cylinder(d=pulley_d+pulley_clearance,h=body_h+1,$fn=fnd*(pulley_d+pulley_clearance));
300 } 301 }
301 // supports 302 // supports
302 // TODO: hardcoded stuff below… 303 // TODO: hardcoded stuff below…
303 if(false) { // parallel 304 if(false) { // parallel
304 for(y=[-gearbox_d:4:gearbox_d]) 305 for(y=[-gearbox_d:4:gearbox_d])
305 translate([0,y-extrusion_width/2,0]) 306 translate([0,y-extrusion_width/2,0])
@@ -317,45 +318,45 @@ module the_extruder(
317 smalld=st_screw_d+2*extrusion_width; 318 smalld=st_screw_d+2*extrusion_width;
318 bigd = spring_d+spring_d_clearance/2; 319 bigd = spring_d+spring_d_clearance/2;
319 hf = (bigd-smalld)/2; 320 hf = (bigd-smalld)/2;
320 translate([-gearbox_d/2+st_shell+st_nut_h+st_shell+smalld,-longwing,filament_elevation]) 321 translate([-gearbox_d/2+st_shell+st_nut_h+st_shell+smalld,-longwing,filament_elevation])
321 rotate([0,90,0]) difference() { 322 rotate([0,90,0]) difference() {
322 union() { 323 union() {
323 cylinder(d1=smalld,d2=bigd,h=hf,$fn=bigd*PI*2); 324 cylinder(d1=smalld,d2=bigd,h=hf,$fn=fnd*bigd);
324 translate([0,0,hf-epsilon]) 325 translate([0,0,hf-epsilon])
325 cylinder(d=bigd,h=hf*2,$fn=bigd*PI*2); 326 cylinder(d=bigd,h=hf*2,$fn=fnd*bigd);
326 } 327 }
327 translate([0,0,-epsilon]) 328 translate([0,0,-epsilon])
328 cylinder(d=st_screw_d,h=2*hf+epsilon,$fn=st_screw_d*PI*2); 329 cylinder(d=st_screw_d,h=2*hf+epsilon,$fn=fnd*st_screw_d);
329 } 330 }
330 } 331 }
331 332
332 module knob() { 333 module knob() {
333 ch = knob_indent_d/2; 334 ch = knob_indent_d/2;
334 translate([0,0,body_h+epsilon]) { 335 translate([0,0,body_h+epsilon]) {
335 mirror([0,0,1]) translate([0,0,-epsilon]) { 336 mirror([0,0,1]) translate([0,0,-epsilon]) {
336 difference() { 337 difference() {
337 cylinder(d=pulley_d,h=knob_bore_l,$fn=pulley_d*PI*2); 338 cylinder(d=pulley_d,h=knob_bore_l,$fn=fnd*pulley_d);
338 translate([0,0,-1]) difference() { 339 translate([0,0,-1]) difference() {
339 cylinder(d=bore_d+knob_bore_d_tolerance,h=knob_bore_l+2); 340 cylinder(d=bore_d+knob_bore_d_tolerance,h=knob_bore_l+2);
340 translate([-bore_d/2-1,bore_dd-bore_d/2+knob_bore_d_tolerance/2,-1]) 341 translate([-bore_d/2-1,bore_dd-bore_d/2+knob_bore_d_tolerance/2,-1])
341 cube([bore_d+2,bore_d/2,knob_bore_l+4]); 342 cube([bore_d+2,bore_d/2,knob_bore_l+4]);
342 } 343 }
343 } 344 }
344 } 345 }
345 difference() { 346 difference() {
346 union() { 347 union() {
347 cylinder(d1=gearbox_d-2*ch,d2=gearbox_d,h=ch+epsilon,$fn=PI*gearbox_d*2); 348 cylinder(d1=gearbox_d-2*ch,d2=gearbox_d,h=ch+epsilon,$fn=fnd*gearbox_d);
348 translate([0,0,ch]) 349 translate([0,0,ch])
349 cylinder(d=gearbox_d,h=knob_h-2*ch+epsilon,$fn=PI*gearbox_d*2); 350 cylinder(d=gearbox_d,h=knob_h-2*ch+epsilon,$fn=fnd*gearbox_d);
350 translate([0,0,knob_h-ch]) 351 translate([0,0,knob_h-ch])
351 cylinder(d1=gearbox_d,d2=gearbox_d-2*ch,h=ch,$fn=PI*gearbox_d*2); 352 cylinder(d1=gearbox_d,d2=gearbox_d-2*ch,h=ch,$fn=fnd*gearbox_d);
352 } 353 }
353 for(a=[0:360/knob_indents:359]) rotate([0,0,a]) 354 for(a=[0:360/knob_indents:359]) rotate([0,0,a])
354 translate([0,gearbox_d/2,-1]) 355 translate([0,gearbox_d/2,-1])
355 cylinder(d=knob_indent_d,h=knob_h+2,$fn=knob_indent_d*PI*2); 356 cylinder(d=knob_indent_d,h=knob_h+2,$fn=fnd*knob_indent_d);
356 } 357 }
357 } 358 }
358 }//knob module 359 }//knob module
359 360
360 mirrorleft() 361 mirrorleft()
361 if(what=="lever") color("green",0.7) lever(); 362 if(what=="lever") color("green",0.7) lever();