From 1fe1a23f295bbfb0e095fd658933a900cfc06fad Mon Sep 17 00:00:00 2001 From: Robert Sheldon Date: Fri, 6 Sep 2019 22:12:49 -0400 Subject: [PATCH] small fixes SMALLEST_POSSIBLE fixes originating from talks in the openSCAD repo about float rounding issues w/r/t STL. couple more I don't remember :confused: --- keys.scad | 5 ++++- src/constants.scad | 1 + src/functions.scad | 4 +++- src/key.scad | 11 ++++++----- src/stem_supports/tines.scad | 5 +++-- src/stems/cherry.scad | 2 +- src/stems/cherry_stabilizer.scad | 2 +- 7 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 src/constants.scad diff --git a/keys.scad b/keys.scad index 6f592ad..fe38b74 100644 --- a/keys.scad +++ b/keys.scad @@ -14,4 +14,7 @@ include include include -key(); +sa_row(3) u(3) stabilized() { + /* %envelope(0); */ + key(); +} diff --git a/src/constants.scad b/src/constants.scad new file mode 100644 index 0000000..8e961e0 --- /dev/null +++ b/src/constants.scad @@ -0,0 +1 @@ +SMALLEST_POSSIBLE = 1/128; diff --git a/src/functions.scad b/src/functions.scad index ca87f50..bd9004b 100644 --- a/src/functions.scad +++ b/src/functions.scad @@ -1,3 +1,5 @@ +include + // I use functions when I need to compute special variables off of other special variables // functions need to be explicitly included, unlike special variables, which // just need to have been set before they are used. hence this file @@ -16,7 +18,7 @@ function cherry_cross(slop, extra_vertical = 0) = [ // horizontal tine [4.03 + slop, 1.15 + slop / 3], // vertical tine - [1.25 + slop / 3, 4.23 + extra_vertical + slop / 3 + .005], + [1.25 + slop / 3, 4.23 + extra_vertical + slop / 3 + SMALLEST_POSSIBLE], ]; // actual mm key width and height diff --git a/src/key.scad b/src/key.scad index 8f82f4e..cc44886 100644 --- a/src/key.scad +++ b/src/key.scad @@ -11,6 +11,7 @@ include /* [Hidden] */ +SMALLEST_POSSIBLE = 1/128; $fs = .1; $unit = 19.05; blue = [.2667,.5882,1]; @@ -22,7 +23,7 @@ transparent_red = [1,0,0, 0.15]; // key shape including dish. used as the ouside and inside shape in keytop(). allows for itself to be shrunk in depth and width / height module shape(thickness_difference, depth_difference){ dished(depth_difference, $inverted_dish) { - color(blue) shape_hull(thickness_difference, depth_difference, 2); + color(blue) shape_hull(thickness_difference, depth_difference, $inverted_dish ? 2 : 0); } } @@ -87,7 +88,7 @@ module shape_slice(progress, thickness_difference, depth_difference) { translate([0, skew_this_slice, depth_this_slice]) { rotate([tilt_this_slice,0,0]){ - linear_extrude(height = 0.001){ + linear_extrude(height = SMALLEST_POSSIBLE){ key_shape( [ total_key_width(thickness_difference), @@ -128,7 +129,7 @@ module envelope(depth_difference) { s = 1.5; hull(){ cube([total_key_width() * s, total_key_height() * s, 0.01], center = true); - top_placement(0.005 + depth_difference){ + top_placement(SMALLEST_POSSIBLE + depth_difference){ cube([top_total_key_width() * s, top_total_key_height() * s, 0.01], center = true); } } @@ -257,7 +258,7 @@ module keytop() { shape(0, 0); } // translation purely for aesthetic purposes, to get rid of that awful lattice - translate([0,0,-0.005]) { + translate([0,0,-SMALLEST_POSSIBLE]) { shape($wall_thickness, $keytop_thickness); } } @@ -289,7 +290,7 @@ module key(inset = false) { if ($stem_type != "disable" || ($stabilizers != [] && $stabilizer_type != "disable")) { dished($keytop_thickness, $inverted_dish) { translate([0, 0, $stem_inset]) { - if ($stabilizer_type != "disable") stems_for($stabilizers, $stabilizer_type); + /* if ($stabilizer_type != "disable") stems_for($stabilizers, $stabilizer_type); */ if ($stem_type != "disable") stems_for($stem_positions, $stem_type); } } diff --git a/src/stem_supports/tines.scad b/src/stem_supports/tines.scad index ca98342..99cb57c 100644 --- a/src/stem_supports/tines.scad +++ b/src/stem_supports/tines.scad @@ -1,8 +1,9 @@ include <../functions.scad> include <../stems/cherry.scad> +// $wall_thickness/4 to reduce coincident faces module centered_tines(stem_support_height) { - if ($key_length < 2) translate([0,0,$stem_support_height / 2]) cube([total_key_width($wall_thickness), 1, $stem_support_height], center = true); + if ($key_length < 2) translate([0,0,$stem_support_height / 2]) cube([total_key_width($wall_thickness)+$wall_thickness/4, 1, $stem_support_height], center = true); translate([0,0,$stem_support_height / 2]) cube([1, total_key_height($wall_thickness), $stem_support_height], center = true); } @@ -10,7 +11,7 @@ module tines_support(stem_type, stem_support_height, slop) { if (stem_type == "cherry" || stem_type == "costar_stabilizer") { difference () { union() { - if ($key_length < 2) translate([0,0,$stem_support_height / 2]) cube([total_key_width($wall_thickness), 1, $stem_support_height], center = true); + if ($key_length < 2) translate([0,0,$stem_support_height / 2]) cube([total_key_width($wall_thickness)+$wall_thickness/4, 1, $stem_support_height], center = true); translate([1.15,0,$stem_support_height / 2]) cube([.5, total_key_height($wall_thickness), $stem_support_height], center = true); translate([-1.15,0,$stem_support_height / 2]) cube([.5, total_key_height($wall_thickness), $stem_support_height], center = true); } diff --git a/src/stems/cherry.scad b/src/stems/cherry.scad index 1f006ae..371f327 100644 --- a/src/stems/cherry.scad +++ b/src/stems/cherry.scad @@ -7,7 +7,7 @@ extra_vertical = 0.6; module inside_cherry_cross(slop) { // inside cross // translation purely for aesthetic purposes, to get rid of that awful lattice - translate([0,0,-0.005]) { + translate([0,0,-SMALLEST_POSSIBLE]) { linear_extrude(height = $stem_throw) { square(cherry_cross(slop, extra_vertical)[0], center=true); square(cherry_cross(slop, extra_vertical)[1], center=true); diff --git a/src/stems/cherry_stabilizer.scad b/src/stems/cherry_stabilizer.scad index 07ce1ae..572b078 100644 --- a/src/stems/cherry_stabilizer.scad +++ b/src/stems/cherry_stabilizer.scad @@ -7,7 +7,7 @@ extra_vertical = 0.6; module inside_cherry_stabilizer_cross(slop) { // inside cross // translation purely for aesthetic purposes, to get rid of that awful lattice - translate([0,0,-0.005]) { + translate([0,0,-SMALLEST_POSSIBLE]) { linear_extrude(height = $stem_throw) { square(cherry_cross(slop, extra_vertical)[0], center=true); square(cherry_cross(slop, extra_vertical)[1], center=true);