switch to intersection instead of difference for dishing. faster and better. uses a clipping envelope around the key

This commit is contained in:
Robert Sheldon 2018-06-30 22:37:24 -04:00
parent be15a0d988
commit bb3b8525d4
6 changed files with 727 additions and 186 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,4 +20,6 @@ include <src/key_transformations.scad>
use <src/key.scad>
key_profile(key_profile, row) legend(legend) key();
key_profile(key_profile, row) legend(legend) {
key();
}

View File

@ -15,7 +15,5 @@ include <src/key_transformations.scad>
//$has_brim=true;
sa_row(3) {
$stem_slop = 0;
key();
}

View File

@ -121,29 +121,42 @@ module top_placement(depth_difference) {
// just to DRY up the code
module _dish() {
color(purple) dish(top_total_key_width() + $dish_overdraw_width, top_total_key_height() + $dish_overdraw_height, $dish_depth, $inverted_dish);
dish(top_total_key_width() + $dish_overdraw_width, top_total_key_height() + $dish_overdraw_height, $dish_depth, $inverted_dish);
}
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){
cube([top_total_key_width() * s, top_total_key_height() * s, 0.01], center = true);
}
}
}
module dished_for_show() {
difference(){
union() {
envelope();
if ($inverted_dish) top_placement(0) _dish();
}
if (!$inverted_dish) top_placement(0) _dish();
}
}
// for when you want to take the dish out of things
// used for adding the dish to the key shape and making sure stems don't stick out the top
// has physical limits, since you can't specify planes in openscad
// maybe I should make a bounding box cube, difference that with the dish then intersect with the children
// creates a bounding box 1.5 times larger in width and height than the keycap.
module dished(depth_difference, inverted = false) {
difference() {
intersection() {
children();
top_placement(depth_difference){
difference(){
union() {
// this weird math here is so Customizer doesn't see a giant shape and zoom out a million miles. could just be cube(1000)
translate([-$key_length * $unit, -$key_height * $unit]) cube([
$key_length*2 * $unit,
$key_height*2 * $unit,
50
]);
if (!inverted) _dish();
}
if (inverted) _dish();
difference(){
union() {
envelope(depth_difference);
if (inverted) top_placement(depth_difference) _dish();
}
if (!inverted) top_placement(depth_difference) _dish();
}
}
}

View File

@ -36,7 +36,7 @@ $wall_thickness = 3;
$corner_radius = 1;
// width of the very bottom of the key
$bottom_key_width = 18.16;
// height (from the front) of the very bottom of the ke
// height (from the front) of the very bottom of the key
$bottom_key_height = 18.16;
// how much less width there is on the top. eg top_key_width = bottom_key_width - width_difference
$width_difference = 6;
@ -51,14 +51,11 @@ $top_skew = 1.7;
/* Stem */
// where the stems are in relation to the center of the keycap, in units. default is one in the center
$stem_positions = [[0,0]];
// how far the throw distance of the switch is. determines how far the 'cross' in the cherry switch digs into the stem, and how long the keystem needs to be before supports can start. luckily, alps and cherries have a pretty similar throw. can modify to have stouter keycaps for low profile switches, etc
$stem_throw = 4;
// diameter of the outside of the rounded cherry stem
$rounded_cherry_stem_d = 5.5;
// dimensions of alps stem
$alps_stem = [4.45, 2.25];
// how much higher the stem is than the bottom of the keycap.
// inset stem requires support but is more accurate in some profiles
@ -66,14 +63,6 @@ $stem_inset = 0;
// how many degrees to rotate the stems. useful for sideways keycaps, maybe
$stem_rotation = 0;
/* Stabilizers */
// ternary is ONLY for customizer. it will NOT work if you're using this in
// openSCAD, unless you're using the customizer. you should use stabilized() or
// set the variable directly
// array of positions of stabilizers
$stabilizers = $key_length > 5.75 ? [[-50, 0], [50, 0]] : [[-12,0],[12,0]];
/* Shape */
// key shape type, determines the shape of the key. default is 'rounded square'
@ -119,13 +108,30 @@ $minkowski_radius = .33;
/* Features */
//list of legends to place on a key format: [text, halign, valign, size]
//halign = "left" or "center" or "right"
//valign = "top" or "center" or "bottom"
$legends = [];
//insert locating bump
$key_bump = false;
//height of the location bump from the top surface of the key
$key_bump_depth = 0.5;
//distance to move the bump from the front edge of the key
$key_bump_edge = 0.4;
/* [Hidden] */
//list of legends to place on a key format: [text, halign, valign, size]
//halign = "left" or "center" or "right"
//valign = "top" or "center" or "bottom"
// currently does not work with thingiverse customizer, and actually breaks it
$legends = [];
// dimensions of alps stem
$alps_stem = [4.45, 2.25];
// ternary is ONLY for customizer. it will NOT work if you're using this in
// openSCAD, unless you're using the customizer. you should use stabilized() or
// set the variable directly
// array of positions of stabilizers
$stabilizers = $key_length > 5.75 ? [[-50, 0], [50, 0]] : [[-12,0],[12,0]];
// where the stems are in relation to the center of the keycap, in units. default is one in the center
// shouldn't work in thingiverse customizer, though it has been...
$stem_positions = [[0,0]];

View File

@ -1,5 +1,5 @@
include <../functions.scad>
include <../cherry.scad>
include <../stems/cherry.scad>
module centered_tines(stem_support_height) {
translate([0,0,$stem_support_height / 2]) cube([total_key_width($wall_thickness), 1, $stem_support_height], center = true);