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 😕
This commit is contained in:
Robert Sheldon 2019-09-06 22:12:49 -04:00
parent 655905d38e
commit 1fe1a23f29
7 changed files with 19 additions and 11 deletions

View File

@ -14,4 +14,7 @@ include <src/key_types.scad>
include <src/key_transformations.scad>
include <src/key_helpers.scad>
sa_row(3) u(3) stabilized() {
/* %envelope(0); */
key();
}

1
src/constants.scad Normal file
View File

@ -0,0 +1 @@
SMALLEST_POSSIBLE = 1/128;

View File

@ -1,3 +1,5 @@
include <constants.scad>
// 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

View File

@ -11,6 +11,7 @@ include <libraries/geodesic_sphere.scad>
/* [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);
}
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);