From dcc13b7d35fe435453bb35796d34116ff54d85ab Mon Sep 17 00:00:00 2001 From: Bob - Home - Windows Date: Sun, 5 Nov 2017 17:56:05 -0500 Subject: [PATCH] switch rounded_shape to use half minkowski sum for height and promote connector slop to full special variable --- dishes.scad | 20 +++++++++++--------- key.scad | 48 ++++++++++++++++++++++++++++-------------------- keys.scad | 17 +++++++++-------- stems.scad | 21 ++++++++++++--------- 4 files changed, 60 insertions(+), 46 deletions(-) diff --git a/dishes.scad b/dishes.scad index 4479e35..ad3aad1 100644 --- a/dishes.scad +++ b/dishes.scad @@ -14,6 +14,9 @@ module dish(width, height, depth, inverted, tilt) { else if ($dish_type == "sideways cylindrical"){ sideways_cylindrical_dish(width, height, depth, inverted, tilt); } + else if ($dish_type == "old spherical") { + old_spherical_dish(width, height, depth, inverted, tilt); + } // else no dish, "no dish" is the value } @@ -68,10 +71,12 @@ module spherical_dish(width, height, depth, inverted, tilt, txt=""){ rotate([-tilt,0,0]){ translate([0,0,0 * direction]){ if (geodesic){ - $fa=10; - geodesic_sphere(r=rad); + $fa=20; + scale([chord/2/depth, chord/2/depth]) { + geodesic_sphere(r=depth); + } } else { - $fa=1; + $fa=7; // rotate 1 because the bottom of the sphere looks like trash. scale([chord/2/depth, chord/2/depth]) { geodesic_sphere(r=depth); @@ -102,15 +107,12 @@ module old_spherical_dish(width, height, depth, inverted, tilt, txt=""){ rotate([-tilt,0,0]){ translate([0,0,chord_length * direction]){ if (geodesic){ - $fa=3; + $fa=7; geodesic_sphere(r=rad); } else { $fa=1; - // rotate 1 because the bottom of the sphere looks like trash. - %difference() { - sphere(r=rad); - translate([0,0,rad]) cube(rad*2, center=true); - } + // rotate 1 because the bottom of the sphere looks like trash + sphere(r=rad); } } } diff --git a/key.scad b/key.scad index 5dbd298..a05b995 100644 --- a/key.scad +++ b/key.scad @@ -12,9 +12,9 @@ wall_thickness = 3; //whether stabilizer connectors are enabled stabilizers = false; // font used for text -font="Arial"; +font="DejaVu Sans Mono:style=Book"; // font size used for text -font_size = 8; +font_size = 6; // whether or not to render fake keyswitches to check clearances clearance_check = false; @@ -71,6 +71,8 @@ text = ""; inset_text = false; // radius of corners of keycap corner_radius = 1; +// keystem slop - lengthens the cross and thins out the connector +slop = 0.3; @@ -90,7 +92,7 @@ $fs = .1; //beginning to use unit instead of baked in 19.05 unit = 19.05; //minkowski radius. radius of sphere used in minkowski sum for minkowski_key function. 1.75 default for faux G20 -$minkowski_radius = .75; +$minkowski_radius = .33; @@ -120,12 +122,15 @@ module shape(thickness_difference, depth_difference){ // shape of the key but with soft, rounded edges. much more realistic, MUCH more complex. orders of magnitude more complex module rounded_shape() { - minkowski(){ - shape($minkowski_radius*2, $minkowski_radius); - difference(){ - sphere(r=$minkowski_radius, $fn=24); - translate([0,0,-$minkowski_radius]) + render(){ + minkowski(){ + // half minkowski. that means the shape is neither circumscribed nor inscribed. + shape($minkowski_radius * 2, $minkowski_radius/2); + difference(){ + sphere(r=$minkowski_radius, $fn=24); + translate([0,0,-$minkowski_radius]) cube([2*$minkowski_radius,2*$minkowski_radius,2*$minkowski_radius], center=true); + } } } } @@ -136,14 +141,16 @@ module rounded_shape() { // $height_difference used for keytop thickness // extra_slices is a hack to make inverted dishes still work module shape_hull(thickness_difference, depth_difference, modifier, extra_slices = 0){ - if ($ISOEnter) { - ISOEnterShapeHull(thickness_difference, depth_difference, modifier); - } else { - slices = 10; - for (index = [0:$height_slices - 1 + extra_slices]) { - hull() { - shape_slice(index, $height_slices, thickness_difference, depth_difference, modifier); - shape_slice(index + 1, $height_slices, thickness_difference, depth_difference, modifier); + render() { + if ($ISOEnter) { + ISOEnterShapeHull(thickness_difference, depth_difference, modifier); + } else { + slices = 10; + for (index = [0:$height_slices - 1 + extra_slices]) { + hull() { + shape_slice(index, $height_slices, thickness_difference, depth_difference, modifier); + shape_slice(index + 1, $height_slices, thickness_difference, depth_difference, modifier); + } } } } @@ -197,7 +204,7 @@ module top_of_key(){ } module keytext() { - extra_inset_depth = ($inset_text) ? keytop_thickness/4 : 0; + extra_inset_depth = ($inset_text) ? 0.3 : 0; translate([0, 0, -extra_inset_depth]){ top_of_key(){ @@ -208,12 +215,12 @@ module keytext() { } } -module connectors(stem_profile) { +module connectors() { intersection() { for (connector_pos = $connectors) { translate([connector_pos[0], connector_pos[1], $stem_inset]) { rotate([0, 0, $stem_rotation]){ - color([1, .6941, .2]) connector(stem_profile, $has_brim); + color([1, .6941, .2]) connector($stem_profile, $has_brim, $slop); } } } @@ -258,7 +265,7 @@ module key() { difference() { union(){ keytop(); - if($stem_profile != "blank") connectors($stem_profile); + if($stem_profile != "blank") connectors(); if(!$inset_text) keytext(); clearance_check(); top_of_key() { @@ -298,6 +305,7 @@ module example_key(){ $corner_radius = corner_radius; $height_slices = height_slices; $enable_side_sculpting = enable_side_sculpting; + $slop = slop; key(); } diff --git a/keys.scad b/keys.scad index 3bfed93..74cf3ad 100644 --- a/keys.scad +++ b/keys.scad @@ -6,6 +6,7 @@ // special variables, but that's a limitation of SCAD we have to work around /* TODO: + * add keys.scad function for fudge factor in stem * pull out side sculpting options to let people tweak them? * can now measure keycaps very accurately. need to redo measurements: [x] SA [ ] DCS [X] DSA [X] OEM? * Add inset stem to all profiles that need it. [x] OEM [ ] DCS? @@ -43,6 +44,7 @@ $text = ""; $inset_text = false; $corner_radius = 1; $height_slices = 1; +$slop = 0.3; // key profile definitions @@ -392,17 +394,20 @@ module blank() { children(); } -module cherry() { +module cherry(slop = 0.3) { + $slop = slop; $stem_profile = "cherry"; children(); } -module alps() { +module alps(slop = 0.3) { + $slop = slop; $stem_profile = "alps"; children(); } -module rounded_cherry() { +module rounded_cherry(slop = 0.3) { + $slop = slop; $stem_profile = "cherry_rounded"; children(); } @@ -413,8 +418,4 @@ module legend(text, inset=false) { children(); } -rows = [4,3,2,1,5]; - - -translate_u(0, 0) dcs_row(1) cherry() key() { -}; +translate_u(0, 0) oem_row(1) cherry() key(); diff --git a/stems.scad b/stems.scad index 9d87a08..2b15ee4 100644 --- a/stems.scad +++ b/stems.scad @@ -11,7 +11,9 @@ module brim(has_brim) { if (has_brim) color([0,1,0]) cube([brim_radius, brim_radius, brim_depth]); } -module cherry_stem(has_brim, slop = 0.3) { +module cherry_stem(has_brim, slop) { + + echo(slop); stem_width = 7.2 - slop * 2; stem_height = 5.5 - slop * 2; @@ -48,12 +50,12 @@ module cherry_stem(has_brim, slop = 0.3) { } } -module cherry_stem_rounded(has_brim) { +module cherry_stem_rounded(has_brim, slop) { // cross length cross_length = 4.4; //dimensions of connector // outer cross extra length in y - extra_outer_cross_height = 1.0; + extra_outer_cross_height = 1.1; // dimensions of cross // horizontal cross bar width horizontal_cross_width = 1.4; @@ -78,7 +80,7 @@ module cherry_stem_rounded(has_brim) { } } -module alps_stem(has_brim = false){ +module alps_stem(has_brim, slop){ cross_depth = 40; width = 4.45; height = 2.25; @@ -92,7 +94,7 @@ module alps_stem(has_brim = false){ } } -module filled_stem(has_brim=false) { +module filled_stem() { // this is mostly for testing. we don't pass the size of the keycp in here // so we can't make this work for all keys cube(100, center=true); @@ -100,13 +102,14 @@ module filled_stem(has_brim=false) { //whole connector, alps or cherry, trimmed to fit -module connector(stem_profile, has_brim){ +module connector(stem_profile, has_brim, slop){ + echo(slop); if (stem_profile == "alps") { - alps_stem(has_brim); + alps_stem(has_brim, slop); } else if (stem_profile == "cherry_rounded") { - cherry_stem_rounded(has_brim); + cherry_stem_rounded(has_brim, slop); } else if (stem_profile == "cherry") { - cherry_stem(has_brim); + cherry_stem(has_brim, slop); } else if (stem_profile == "filled") { filled_stem(); }