Commit beb06ed4 authored by György Kurucz's avatar György Kurucz
Browse files

Add screw library, move some files around.

parent 733d3481
module _screw_thread(N=10, R=10, R_min=12, R_maj=15, P=3, taper=true) {
function concat(P) = [for(L=P, a=L) a];
function taper_fn(n) = max(0.001, min(n, 1));
alpha_deg = 60;
//P = 2*H*tan(alpha_deg/2);
H = P/(2*tan(alpha_deg/2));
assert(R <= R_min && R_min <= R_maj && R_maj <= R+H);
L_min = tan(alpha_deg/2)*(R_min-R)*2;
L_maj = tan(alpha_deg/2)*(R+H-R_maj)*2;
N_level = 100;
step = 1/N_level;
N_pieces = N * N_level;
points_mid = [ for (n=[0:N_pieces-1]) each
let(a=360*n*step, c=cos(a), s=sin(a),
t=(taper?taper_fn(n*step):1)*(R_maj-R_min)) [
[ c*R_min, L_min/2 + P*(n*step), s*R_min ],
[ c*(R_min+t), -L_maj/2 + P*(n*step+0.5), s*(R_min+t) ],
[ c*(R_min+t), L_maj/2 + P*(n*step+0.5), s*(R_min+t) ],
[ c*R_min, -L_min/2 + P*(n*step+1), s*R_min ]
] ];
points_end = [ [ 0, P*N, 0], [0, P, 0] ];
point_end = N_pieces*4;
point_bot = N_pieces*4+1;
faces_mid = [ for (n=[0:N_pieces-2]) each [
[ n*4, n*4+4, n*4+4+1, n*4+1 ],
[ n*4+1, n*4+4+1, n*4+4+2, n*4+2 ],
[ n*4+2, n*4+4+2, n*4+4+3, n*4+3 ]
] ];
faces_lev = [ for (n=[0:N_pieces-N_level-2])
[ n*4+3, n*4+4+3, (n+N_level)*4+4, (n+N_level)*4 ]
];
faces_end = concat([[ for (n=[0:N_level-1]) each [
[ (n-1+N_level*(N-1))*4+3, (n-1+N_level*(N-1))*4+4+3, point_end ],
[ n*4, point_bot, (n+1)*4 ]
]], [
[ (N_pieces-1)*4, (N_pieces-1)*4+3, (N_pieces-1)*4+2, (N_pieces-1)*4+1 ],
[ (N_pieces-N_level-1)*4+3, point_end, (N_pieces-1)*4 ],
[ (N_pieces-1)*4, point_end, (N_pieces-1)*4+3 ],
[ 3, 0, 1, 2 ],
[ N_level*4, point_bot, 3 ],
[ 3, point_bot, 0 ]
]]);
translate([0,0,-P/2]) mirror([1,0,0]) rotate([90,0,0]) polyhedron(
concat([ points_mid, points_end ]),
concat([ faces_mid, faces_lev, faces_end ]),
convexity=10
);
}
module metric_screw(P=3, D_maj=14, tol=0, h=30, taper=true) {
R_maj=D_maj/2+tol;
R_min=R_maj-5/16*sqrt(3)*P;
R=R_min-sqrt(3)/8*P;
N=ceil(h/P);
intersection() {
union() {
_screw_thread(N=N, R=R, R_min=R_min,
R_maj=R_maj, P=P, taper=taper);
translate([0,0,-1]) cylinder(r=R_min, h=P*(N+1), $fn=100);
}
translate([-50,-50,0]) cube([100, 100, h]);
}
}
/* union() {
difference() {
rotate([0,0,30]) cylinder(r=10, $fn=6, h=25.8);
translate([0,0,-3]) metric_screw(tol=0.5, do_taper=false);
}
translate([17,0,0]) difference() {
metric_screw();
translate([0,0,-1]) rotate([0,0,30])
cylinder(r=4/sqrt(3)+0.2, $fn=6, h=100);
}
} */
label = "STwzYmVlciEK";
label = "PV=nRT";
rotate_text = 0; //0: right handed, 180: left handed
//================
module txt() {
translate([-15,0,10])
translate([-8,0,10.7])
rotate([0,-4,0])
linear_extrude(3, convexity=3)
rotate([0, 0, rotate_text])
......@@ -14,8 +14,8 @@ module txt() {
}
difference() {
rotate([90,0,0]) import("bottle_opener.stl", convexity=4);
rotate([90,0,0]) import("../assets/bottle_opener.stl", convexity=4);
txt();
}
//txt();
\ No newline at end of file
//txt();
d_base = 51 + 5;
h_base = 4.2;
d = (42.2 + 47.8) / 2;
h = 17.8;
d_inner = 38.5;
cr = 1.6;
$fn = 100;
difference() {
union() {
translate([0,0,cr]) minkowski() {
cylinder(h=h_base-2*cr, d=d_base-2*cr);
sphere(r=cr);
}
translate([0,0,h_base/2])
cylinder(h=h_base/2, d=d_base);
cylinder(h=h, d=d);
}
translate([0, 0, h_base])
cylinder(h=h, d=d_inner);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment