tweak ISO_enter.scad

backporting some changes I made a while ago on the new key structure branch
This commit is contained in:
Bob 2020-08-23 17:42:30 -04:00
parent 24e280fe3c
commit d4321abd40
1 changed files with 27 additions and 24 deletions

View File

@ -2,6 +2,10 @@
// NOT 3D // NOT 3D
function unit_length(length) = unit * (length - 1) + 18.16; function unit_length(length) = unit * (length - 1) + 18.16;
width_ratio = unit_length(1.25) / unit_length(1.5);
height_ratio = unit_length(1) / unit_length(2);
module ISO_enter_shape(size, delta, progress){ module ISO_enter_shape(size, delta, progress){
width = size[0]; width = size[0];
height = size[1]; height = size[1];
@ -13,43 +17,42 @@ module ISO_enter_shape(size, delta, progress){
// and wants to pass just width and height, we make these ratios to know where // and wants to pass just width and height, we make these ratios to know where
// to put the elbow joint // to put the elbow joint
width_ratio = unit_length(1.25) / unit_length(1.5); delta = delta / 2;
height_ratio = unit_length(1) / unit_length(2);
pointArray = [ pointArray = [
[ 0, 0], // top right [ 0-delta.x, 0-delta.y], // top right
[ 0, -height], // bottom right [ 0-delta.x, -height+delta.y], // bottom right
[-width * width_ratio, -height], // bottom left [-width * width_ratio+delta.x, -height+delta.y], // bottom left
[-width * width_ratio,-height * height_ratio], // inner middle point [-width * width_ratio + delta.x,-height * height_ratio+delta.y], // inner middle point
[ -width,-height * height_ratio], // outer middle point [ -width + delta.x,-height * height_ratio + delta.y], // outer middle point
[ -width, 0] // top left [ -width + delta.x, 0-delta.y] // top left
]; ];
minkowski(){ minkowski(){
circle(r=corner_size); circle(r=$corner_radius);
// gives us rounded inner corner // gives us rounded inner corner
offset(r=-corner_size*2) { offset(r=-$corner_radius*2) {
translate([(width * width_ratio)/2, height/2]) polygon(points=pointArray); translate([(width * width_ratio)/2, height/2]) polygon(points=pointArray);
} }
} }
} }
function iso_enter_vertices(width, height, width_ratio, height_ratio, wd, hd) = [ function iso_enter_vertices(size, delta, progress, thickness_difference) = [
[ 0-wd, 0-hd], // top right [ 0-delta.x/2 * progress - thickness_difference/2, 0 - delta.y / 2 * progress - thickness_difference/2], // top right
[ 0-wd, -height+hd], // bottom right [ 0-delta.x/2 * progress - thickness_difference/2, -size[1] + delta.y / 2 * progress + thickness_difference/2], // bottom right
[-width * width_ratio+wd, -height+hd], // bottom left [-size[0] * width_ratio + delta.x/2 * progress + thickness_difference/2, -size[1] + delta.y / 2 * progress + thickness_difference/2], // bottom left
[-width * width_ratio+wd,-height * height_ratio+hd], // inner middle point [-size[0] * width_ratio + delta.x/2 * progress + thickness_difference/2,-size[1] * height_ratio + delta.y / 2 * progress + thickness_difference/2], // inner middle point
[ -width+wd,-height * height_ratio+hd], // outer middle point [ -size[0] + delta.x/2 * progress + thickness_difference/2,-size[1] * height_ratio + delta.y / 2 * progress + thickness_difference/2], // outer middle point
[ -width+wd, 0-hd] // top left [ -size[0] + delta.x/2 * progress + thickness_difference/2, 0 - delta.y / 2 * progress - thickness_difference/2] // top left
] + [ ] + [
[(width * width_ratio)/2, height/2 ], [(size[0] * width_ratio)/2, size[1]/2 ],
[(width * width_ratio)/2, height/2 ], [(size[0] * width_ratio)/2, size[1]/2 ],
[(width * width_ratio)/2, height/2 ], [(size[0] * width_ratio)/2, size[1]/2 ],
[(width * width_ratio)/2, height/2 ], [(size[0] * width_ratio)/2, size[1]/2 ],
[(width * width_ratio)/2, height/2 ], [(size[0] * width_ratio)/2, size[1]/2 ],
[(width * width_ratio)/2, height/2 ] [(size[0] * width_ratio)/2, size[1]/2 ]
]; ];
// no rounding on the corners at all // no rounding on the corners at all
function skin_iso_enter_shape(size, delta, progress, thickness_difference) = function skin_iso_enter_shape(size, delta, progress, thickness_difference) =
iso_enter_vertices(size.x, size.y, unit_length(1.25) / unit_length(1.5), unit_length(1) / unit_length(2), thickness_difference/2 + delta.x * progress/2, thickness_difference/2 + delta.y * progress/2); iso_enter_vertices(size, delta, progress, thickness_difference);