Switch focus to 2d to avoid 3d mink

This commit is contained in:
Quinn
2022-01-09 13:12:11 -08:00
parent 5352041c8c
commit c29045b4c2
2 changed files with 48 additions and 15 deletions
+7 -15
View File
@@ -56,28 +56,20 @@ function throw_faces(points) = let(length = len(points), half = len(points) / 2)
function lerp(a,b,t) = a + (b - a) * t; function lerp(a,b,t) = a + (b - a) * t;
module shape_gate (shape, throw, shaft_r, sharpness = 0) { module shape_gate (shape, throw, shaft_r, sharpness = 1) {
sharpness = lerp(1, shaft_r, max(0, min(sharpness, 1))); corner_r = shaft_r * sharpness;
corner_offset = shaft_r - corner_r;
corner_r = shaft_r / sharpness;
corner_offset = corner_r * (sharpness - 1);
points = throw_points(shape, throw, corner_offset); points = throw_points(shape, throw, corner_offset);
echo(points);
echo(corner_offset);
echo(abs(corner_offset) * tan(throw));
difference(){
minkowski(){ minkowski(){
polyhedron(points, throw_faces(points)); polyhedron(points, throw_faces(points));
cylinder(1, corner_r); cylinder(1, corner_r);
} }
translate([0,0,gate_height + 16])
cube(32, true);
}
} }
sharpness = sin(180 * $t); sharpness = $t;
echo(sharpness); echo(sharpness);
shape_gate(sq_poly, 10, 9 / 2, sharpness); shape_gate(sq_poly, 10, 9 / 2, 1);
+41
View File
@@ -0,0 +1,41 @@
$fn=32;
scale = 1;
card = scale;
corn = scale / sqrt(2);
function scale_xy(xy, m) = [ for (i = m) [i.x * xy, i.y * xy]];
function normalize(vec) = vec / norm(vec);
function grow(shape, mag) = [ for (i = shape) i + normalize(i) * mag];
function add_radius(shape, rad) = grow(shape, rad/cos(180/len(shape)));
function lerp(a,b,t) = a + (b - a) * t;
module round_poly(shape, radius, sharpness = 0){
corner_r = lerp(radius, 0, sharpness);
corner_offset = lerp(0, radius, sharpness);
minkowski(){
polygon(add_radius(shape,corner_offset));
circle(max(corner_r, 0.0001));
}
}
oct = [
[card,0],
[corn,corn],
[0,card],
[-corn,corn],
[-card,0],
[-corn,-corn],
[0,-card],
[corn,-corn]
];
radius = 1;
round_poly(oct,radius, 1);