From 5f8325d27264b275cf2d90ca4a82664dd4f7a5a2 Mon Sep 17 00:00:00 2001 From: daniel watson Date: Sat, 25 Feb 2017 23:54:13 -0800 Subject: [PATCH] make spin with slices using fast layer height --- spin-data.scad | 131 +++++++++++++++++++++++++++++++++---------------- spin.scad | 22 ++++----- 2 files changed, 99 insertions(+), 54 deletions(-) diff --git a/spin-data.scad b/spin-data.scad index 0c83d85..4d4fd0d 100644 --- a/spin-data.scad +++ b/spin-data.scad @@ -4,7 +4,7 @@ /* spin thing that erin likes */ $fn = 50; -layer_height = 0.15; +layer_height = 0.35; weight = "penny"; // weight = "608zz"; @@ -69,35 +69,55 @@ module cap(bearing_inner_radius, module fillet(r) { offset(r = -r) { offset(delta = r) { children(); } } } -module spin_footprint(weight_radius, - bearing_radius, - round_extra, - wall, - arms) { - thinner_radius = (bearing_radius < weight_radius)? - bearing_radius : weight_radius; - fillet(thinner_radius / 2) { - for(arm = [0 : arms - 1]) { - hull() { - circle(bearing_radius + round_extra); - rotate( (arm / arms) * 360 ) { - translate([bearing_radius + wall + weight_radius, 0]) { - circle(weight_radius + round_extra); } } } } } } - module mirrored(axis) { children(); mirror(axis) children(); } -module spin(weight_radius, - weight_thickness, - bearing_radius, - bearing_thickness, - weight_lip_overhang = 0.3, - bearing_lip_overhang = 0.3, - wall = 3, - arms = 3, - layer_height = 0.15) { - layer_height = 0.15; +module spin_slice(weight_radius, + bearing_radius, + round_extra, + wall, + arms) { + joiner_radius = (bearing_radius + weight_radius) / 2; + + bearing_xy = [0, 0]; + // a = side along x axis + a = bearing_radius + weight_radius + wall; + // b = side from center to joiner + b = bearing_radius + joiner_radius + round_extra; + // c = side between joiner and arm center + c = joiner_radius + weight_radius + round_extra; + + weight_xy = [a, 0]; + + cos_C = (pow(a, 2) + pow(b, 2) - pow(c, 2)) / (2 * a * b); + sin_C = sqrt(1 - pow(cos_C, 2)); + + joiner_xy = [cos_C, sin_C] * b; + + for(arm = [0 : arms - 1]) { + rotate(arm * (360 / arms)) { + difference() { + union() { + translate(bearing_xy) { + circle(bearing_radius + round_extra); } + translate(weight_xy) { + circle(weight_radius + round_extra); } + mirrored([0, 1]) { + polygon([bearing_xy, weight_xy, joiner_xy]); } } + mirrored([0, 1]) { + translate(joiner_xy) { + circle(joiner_radius); } } } } } } + +module spin_slices(weight_radius, + weight_thickness, + bearing_radius, + bearing_thickness, + weight_lip_overhang = 0.3, + bearing_lip_overhang = 0.3, + wall = 3, + arms = 3, + layer_height = 0.15) { thicker_thickness = (bearing_thickness > weight_thickness) ? bearing_thickness : weight_thickness; calculated_height = thicker_thickness + 2 * wall; @@ -105,10 +125,18 @@ module spin(weight_radius, actual_height = layers * layer_height; round_radius = actual_height / 2; + /* rounding the outside edge of the spinner with a semi-circle leads + to a shape that an overhang on the second layer several times the + thickness of a printed extrusion width. + + rather than using a full semi-circle, this code aims to use just the + portion in the middle, where the overhang is less severe */ old_start = 0; old_end = (layers / 2) - 1; - new_start = old_end / 16; + /* add one to have some thickness all around weight holes + for first layer */ + new_start = old_end / 8 + 1; new_end = old_end; old_range = old_end - old_start; @@ -116,24 +144,41 @@ module spin(weight_radius, factor = new_range / old_range; - initial_adjacent = round_radius - (new_start * layer_height); + /* initial adjacent is adjusted to (new start - 1) to allow some + thickness all around weight holes on first layer */ + initial_adjacent = round_radius - ((new_start - 1) * layer_height); initial_angle = acos(initial_adjacent / round_radius); initial_round_extra = initial_adjacent * tan(initial_angle); - - mirrored([0, 0, 1]) { - for(layer = [0 : (layers / 2) - 1]) { - translate([0, 0, layer * layer_height - actual_height / 2]) { - linear_extrude(height = layer_height) { - new_layer = (layer - old_start) * factor + new_start; - adjacent = round_radius - (new_layer * layer_height); - angle = acos(adjacent / round_radius); - round_extra = adjacent * tan(angle) - initial_round_extra; - echo(round_extra); - spin_footprint(weight_radius, - bearing_radius, - round_extra, - wall, - arms); } } } } } + + difference() { + mirrored([0, 0, 1]) { + for(layer = [0 : (layers / 2) - 1]) { + translate([0, 0, layer * layer_height - actual_height / 2]) { + linear_extrude(height = layer_height) { + new_layer = (layer - old_start) * factor + new_start; + adjacent = round_radius - (new_layer * layer_height); + angle = acos(adjacent / round_radius); + round_extra = adjacent * tan(angle) - initial_round_extra; + spin_slice(weight_radius, + bearing_radius, + round_extra, + wall, + arms); } } } } + cylinder(h = actual_height + 0.1, + r = bearing_radius - bearing_lip_overhang, + center = true); + cylinder(h = bearing_thickness + 0.1, + r = bearing_radius + 0.1, + center = true); + for(arm = [0 : arms - 1]) { + rotate(arm * (360 / arms)) { + translate([bearing_radius + wall + weight_radius, 0]) { + cylinder(h = actual_height + 0.1, + r = weight_radius - weight_lip_overhang, + center = true); + cylinder(h = weight_thickness + 0.1, + r = weight_radius + 0.1, + center = true); } } } } } /* This file is part of 3d-printables. diff --git a/spin.scad b/spin.scad index 3697f5e..1d3bfb8 100644 --- a/spin.scad +++ b/spin.scad @@ -4,18 +4,18 @@ /* spin thing that erin likes */ include -object = "spin"; +object = "spin_slices"; -if (object == "spin") { - spin(weight_radius, - weight_thickness, - bearing_radius, - bearing_thickness, - weight_lip_overhang, - bearing_lip_overhang, - wall, - arms, - layer_height); } +if (object == "spin_slices") { + spin_slices(weight_radius, + weight_thickness, + bearing_radius, + bearing_thickness, + weight_lip_overhang, + bearing_lip_overhang, + wall, + arms, + layer_height); } else if (object == "cap") { cap(bearing_inner_radius, bearing_cap_footprint_radius, -- 2.30.2