switch rounded_shape to use half minkowski sum for height and promote connector slop to full special variable

This commit is contained in:
Bob - Home - Windows 2017-11-05 17:56:05 -05:00
parent e23dae799b
commit dcc13b7d35
4 changed files with 60 additions and 46 deletions

View File

@ -14,6 +14,9 @@ module dish(width, height, depth, inverted, tilt) {
else if ($dish_type == "sideways cylindrical"){ else if ($dish_type == "sideways cylindrical"){
sideways_cylindrical_dish(width, height, depth, inverted, tilt); 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 // 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]){ rotate([-tilt,0,0]){
translate([0,0,0 * direction]){ translate([0,0,0 * direction]){
if (geodesic){ if (geodesic){
$fa=10; $fa=20;
geodesic_sphere(r=rad); scale([chord/2/depth, chord/2/depth]) {
geodesic_sphere(r=depth);
}
} else { } else {
$fa=1; $fa=7;
// rotate 1 because the bottom of the sphere looks like trash. // rotate 1 because the bottom of the sphere looks like trash.
scale([chord/2/depth, chord/2/depth]) { scale([chord/2/depth, chord/2/depth]) {
geodesic_sphere(r=depth); geodesic_sphere(r=depth);
@ -102,15 +107,12 @@ module old_spherical_dish(width, height, depth, inverted, tilt, txt=""){
rotate([-tilt,0,0]){ rotate([-tilt,0,0]){
translate([0,0,chord_length * direction]){ translate([0,0,chord_length * direction]){
if (geodesic){ if (geodesic){
$fa=3; $fa=7;
geodesic_sphere(r=rad); geodesic_sphere(r=rad);
} else { } else {
$fa=1; $fa=1;
// rotate 1 because the bottom of the sphere looks like trash. // rotate 1 because the bottom of the sphere looks like trash
%difference() {
sphere(r=rad); sphere(r=rad);
translate([0,0,rad]) cube(rad*2, center=true);
}
} }
} }
} }

View File

@ -12,9 +12,9 @@ wall_thickness = 3;
//whether stabilizer connectors are enabled //whether stabilizer connectors are enabled
stabilizers = false; stabilizers = false;
// font used for text // font used for text
font="Arial"; font="DejaVu Sans Mono:style=Book";
// font size used for text // font size used for text
font_size = 8; font_size = 6;
// whether or not to render fake keyswitches to check clearances // whether or not to render fake keyswitches to check clearances
clearance_check = false; clearance_check = false;
@ -71,6 +71,8 @@ text = "";
inset_text = false; inset_text = false;
// radius of corners of keycap // radius of corners of keycap
corner_radius = 1; 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 //beginning to use unit instead of baked in 19.05
unit = 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. radius of sphere used in minkowski sum for minkowski_key function. 1.75 default for faux G20
$minkowski_radius = .75; $minkowski_radius = .33;
@ -120,14 +122,17 @@ 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 // shape of the key but with soft, rounded edges. much more realistic, MUCH more complex. orders of magnitude more complex
module rounded_shape() { module rounded_shape() {
render(){
minkowski(){ minkowski(){
shape($minkowski_radius*2, $minkowski_radius); // half minkowski. that means the shape is neither circumscribed nor inscribed.
shape($minkowski_radius * 2, $minkowski_radius/2);
difference(){ difference(){
sphere(r=$minkowski_radius, $fn=24); sphere(r=$minkowski_radius, $fn=24);
translate([0,0,-$minkowski_radius]) translate([0,0,-$minkowski_radius])
cube([2*$minkowski_radius,2*$minkowski_radius,2*$minkowski_radius], center=true); cube([2*$minkowski_radius,2*$minkowski_radius,2*$minkowski_radius], center=true);
} }
} }
}
} }
// basic key shape, no dish, no inside // basic key shape, no dish, no inside
@ -136,6 +141,7 @@ module rounded_shape() {
// $height_difference used for keytop thickness // $height_difference used for keytop thickness
// extra_slices is a hack to make inverted dishes still work // extra_slices is a hack to make inverted dishes still work
module shape_hull(thickness_difference, depth_difference, modifier, extra_slices = 0){ module shape_hull(thickness_difference, depth_difference, modifier, extra_slices = 0){
render() {
if ($ISOEnter) { if ($ISOEnter) {
ISOEnterShapeHull(thickness_difference, depth_difference, modifier); ISOEnterShapeHull(thickness_difference, depth_difference, modifier);
} else { } else {
@ -147,6 +153,7 @@ module shape_hull(thickness_difference, depth_difference, modifier, extra_slices
} }
} }
} }
}
} }
module shape_slice(index, total, thickness_difference, depth_difference, modifier) { module shape_slice(index, total, thickness_difference, depth_difference, modifier) {
@ -197,7 +204,7 @@ module top_of_key(){
} }
module keytext() { 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]){ translate([0, 0, -extra_inset_depth]){
top_of_key(){ top_of_key(){
@ -208,12 +215,12 @@ module keytext() {
} }
} }
module connectors(stem_profile) { module connectors() {
intersection() { intersection() {
for (connector_pos = $connectors) { for (connector_pos = $connectors) {
translate([connector_pos[0], connector_pos[1], $stem_inset]) { translate([connector_pos[0], connector_pos[1], $stem_inset]) {
rotate([0, 0, $stem_rotation]){ 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() { difference() {
union(){ union(){
keytop(); keytop();
if($stem_profile != "blank") connectors($stem_profile); if($stem_profile != "blank") connectors();
if(!$inset_text) keytext(); if(!$inset_text) keytext();
clearance_check(); clearance_check();
top_of_key() { top_of_key() {
@ -298,6 +305,7 @@ module example_key(){
$corner_radius = corner_radius; $corner_radius = corner_radius;
$height_slices = height_slices; $height_slices = height_slices;
$enable_side_sculpting = enable_side_sculpting; $enable_side_sculpting = enable_side_sculpting;
$slop = slop;
key(); key();
} }

View File

@ -6,6 +6,7 @@
// special variables, but that's a limitation of SCAD we have to work around // special variables, but that's a limitation of SCAD we have to work around
/* TODO: /* TODO:
* add keys.scad function for fudge factor in stem
* pull out side sculpting options to let people tweak them? * 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? * 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? * Add inset stem to all profiles that need it. [x] OEM [ ] DCS?
@ -43,6 +44,7 @@ $text = "";
$inset_text = false; $inset_text = false;
$corner_radius = 1; $corner_radius = 1;
$height_slices = 1; $height_slices = 1;
$slop = 0.3;
// key profile definitions // key profile definitions
@ -392,17 +394,20 @@ module blank() {
children(); children();
} }
module cherry() { module cherry(slop = 0.3) {
$slop = slop;
$stem_profile = "cherry"; $stem_profile = "cherry";
children(); children();
} }
module alps() { module alps(slop = 0.3) {
$slop = slop;
$stem_profile = "alps"; $stem_profile = "alps";
children(); children();
} }
module rounded_cherry() { module rounded_cherry(slop = 0.3) {
$slop = slop;
$stem_profile = "cherry_rounded"; $stem_profile = "cherry_rounded";
children(); children();
} }
@ -413,8 +418,4 @@ module legend(text, inset=false) {
children(); children();
} }
rows = [4,3,2,1,5]; translate_u(0, 0) oem_row(1) cherry() key();
translate_u(0, 0) dcs_row(1) cherry() key() {
};

View File

@ -11,7 +11,9 @@ module brim(has_brim) {
if (has_brim) color([0,1,0]) cube([brim_radius, brim_radius, brim_depth]); 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_width = 7.2 - slop * 2;
stem_height = 5.5 - 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
cross_length = 4.4; cross_length = 4.4;
//dimensions of connector //dimensions of connector
// outer cross extra length in y // outer cross extra length in y
extra_outer_cross_height = 1.0; extra_outer_cross_height = 1.1;
// dimensions of cross // dimensions of cross
// horizontal cross bar width // horizontal cross bar width
horizontal_cross_width = 1.4; 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; cross_depth = 40;
width = 4.45; width = 4.45;
height = 2.25; 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 // 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 // so we can't make this work for all keys
cube(100, center=true); cube(100, center=true);
@ -100,13 +102,14 @@ module filled_stem(has_brim=false) {
//whole connector, alps or cherry, trimmed to fit //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") { if (stem_profile == "alps") {
alps_stem(has_brim); alps_stem(has_brim, slop);
} else if (stem_profile == "cherry_rounded") { } else if (stem_profile == "cherry_rounded") {
cherry_stem_rounded(has_brim); cherry_stem_rounded(has_brim, slop);
} else if (stem_profile == "cherry") { } else if (stem_profile == "cherry") {
cherry_stem(has_brim); cherry_stem(has_brim, slop);
} else if (stem_profile == "filled") { } else if (stem_profile == "filled") {
filled_stem(); filled_stem();
} }