add filets

This commit is contained in:
zhao
2023-06-18 14:34:08 -04:00
parent 064e43397f
commit 59cf26a686
23 changed files with 109 additions and 17 deletions

View File

@ -0,0 +1,42 @@
include <./halfspace.scad>
include <./math.scad>
// Some modules for simple subtractive filets
module cylindricalFiletNegative(p0, p1, n, r) {
l = norm(p1-p0);
align_to(p0=p0, p1=p1, p2=p0-n)
rotate(a=[45,0,0])
rotate(a=[0,90,0])
zFiletNegative(length = l, r = r);
}
module zFiletNegative(length, r) {
p1 = [0,0,0];
p2 = [0,0,length];
n1 = [-1,-1,0] / norm([-1,-1,0]);
dr = sqrt(2*r^2);
difference() {
hull() {
translate(v=[0,0,0])
cube(size=[r,r,r]);
translate(v = p2-[0,0,0.1])
cube(size=[r,r,0.1]);
}
hull() {
translate(v = p1-n1*dr)
cylinder(r = r, h=0.0001, $fn = 32);
translate(v = p2-n1*dr)
cylinder(r = r, h=0.0001, $fn = 32);
}
}
}

View File

@ -10,16 +10,17 @@ module halfspace(vpos, p) {
cube(size=[inf, inf, inf], center=true);
} else {
translate(p)
align(a=ref, b = vpos)
alignPlanar(a=ref, b = vpos)
translate(v = [0, 0, -inf/2])
cube(size = [inf, inf, inf], center = true);
}
module align(a,b) {
rot_axis = cross(a,b);
angle = acos(a*b/(norm(a)*norm(b)));
}
rotate(v=rot_axis, a=angle)
children(0);
}
module alignPlanar(a,b) {
rot_axis = cross(a,b);
angle = acos(a*b/(norm(a)*norm(b)));
rotate(v=rot_axis, a=angle)
children(0);
}

View File

@ -24,4 +24,28 @@ module mirror4XY(p, dx, dy) {
children(0);
}
// Generate a 4x4 matrix that causes a change of basis
// such that the origin is at point p0, the x axis is aligned
// from p0 to p1 and point p2 is in the first quadrant.
// Copied and pasted from https://trmm.net/Basis/
module align_to(p0,p1,p2) {
x = unit(p1-p0);
yp = unit(p2-p0);
z = unit(cross(x,yp));
y = unit(cross(z,x));
echo(p0,p1,p2);
echo(x,y,z);
multmatrix([
[x[0], y[0], z[0], p0[0]],
[x[1], y[1], z[1], p0[1]],
[x[2], y[2], z[2], p0[2]],
[ 0, 0, 0, 1]
])
children();
}
function unit(v) = v/norm(v);
function lerp(a, b, t) = (b * t + a * (1 - t));