mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Enable taper and better higbee in thread_helix()
This commit is contained in:
parent
0a6b899404
commit
cc4e4ff402
4 changed files with 95 additions and 79 deletions
|
@ -110,12 +110,12 @@ module pco1810_neck(wall=2, anchor="support-ring", spin=0, orient=UP)
|
||||||
bottom_half() {
|
bottom_half() {
|
||||||
difference() {
|
difference() {
|
||||||
thread_helix(
|
thread_helix(
|
||||||
base_d=threadbase_d-0.1,
|
d=threadbase_d-0.1,
|
||||||
pitch=thread_pitch,
|
pitch=thread_pitch,
|
||||||
thread_depth=thread_h+0.1,
|
thread_depth=thread_h+0.1,
|
||||||
thread_angle=thread_angle,
|
thread_angle=thread_angle,
|
||||||
twist=810,
|
twist=810,
|
||||||
higbee=75,
|
higbee=thread_h*2,
|
||||||
anchor=TOP
|
anchor=TOP
|
||||||
);
|
);
|
||||||
zrot_copies(rots=[90,270]) {
|
zrot_copies(rots=[90,270]) {
|
||||||
|
@ -192,7 +192,7 @@ module pco1810_cap(wall=2, texture="none", anchor=BOTTOM, spin=0, orient=UP)
|
||||||
}
|
}
|
||||||
up(wall) cyl(d=cap_id, h=tamper_ring_h+wall, anchor=BOTTOM);
|
up(wall) cyl(d=cap_id, h=tamper_ring_h+wall, anchor=BOTTOM);
|
||||||
}
|
}
|
||||||
up(wall+2) thread_helix(base_d=thread_od-thread_depth*2, pitch=thread_pitch, thread_depth=thread_depth, thread_angle=thread_angle, twist=810, higbee=45, internal=true, anchor=BOTTOM);
|
up(wall+2) thread_helix(d=thread_od-thread_depth*2, pitch=thread_pitch, thread_depth=thread_depth, thread_angle=thread_angle, twist=810, higbee=thread_depth, internal=true, anchor=BOTTOM);
|
||||||
}
|
}
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
|
@ -303,12 +303,12 @@ module pco1881_neck(wall=2, anchor="support-ring", spin=0, orient=UP)
|
||||||
up(h-lip_h) {
|
up(h-lip_h) {
|
||||||
difference() {
|
difference() {
|
||||||
thread_helix(
|
thread_helix(
|
||||||
base_d=threadbase_d-0.1,
|
d=threadbase_d-0.1,
|
||||||
pitch=thread_pitch,
|
pitch=thread_pitch,
|
||||||
thread_depth=thread_h+0.1,
|
thread_depth=thread_h+0.1,
|
||||||
thread_angle=thread_angle,
|
thread_angle=thread_angle,
|
||||||
twist=650,
|
twist=650,
|
||||||
higbee=75,
|
higbee=thread_h*2,
|
||||||
anchor=TOP
|
anchor=TOP
|
||||||
);
|
);
|
||||||
zrot_copies(rots=[90,270]) {
|
zrot_copies(rots=[90,270]) {
|
||||||
|
@ -376,7 +376,7 @@ module pco1881_cap(wall=2, texture="none", anchor=BOTTOM, spin=0, orient=UP)
|
||||||
}
|
}
|
||||||
up(wall) cyl(d=28.58, h=11.2+wall, anchor=BOTTOM);
|
up(wall) cyl(d=28.58, h=11.2+wall, anchor=BOTTOM);
|
||||||
}
|
}
|
||||||
up(wall+2) thread_helix(base_d=25.5, pitch=2.7, thread_depth=1.6, thread_angle=15, twist=650, higbee=45, internal=true, anchor=BOTTOM);
|
up(wall+2) thread_helix(d=25.5, pitch=2.7, thread_depth=1.6, thread_angle=15, twist=650, higbee=1.6, internal=true, anchor=BOTTOM);
|
||||||
}
|
}
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
|
|
87
paths.scad
87
paths.scad
|
@ -950,14 +950,16 @@ module extrude_from_to(pt1, pt2, convexity, twist, scale, slices) {
|
||||||
|
|
||||||
// Module: spiral_sweep()
|
// Module: spiral_sweep()
|
||||||
// Description:
|
// Description:
|
||||||
// Takes a closed 2D polygon path, centered on the XY plane, and sweeps/extrudes it along a 3D spiral path
|
// Takes a closed 2D polygon path, centered on the XY plane, and sweeps/extrudes it along a 3D spiral path.
|
||||||
// of a given radius, height and twist.
|
// of a given radius, height and twist.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// path = Array of points of a polygon path, to be extruded.
|
// poly = Array of points of a polygon path, to be extruded.
|
||||||
// h = height of the spiral to extrude along.
|
// h = height of the spiral to extrude along.
|
||||||
// r = Radius of the spiral to extrude along. Default: 50
|
// r = Radius of the spiral to extrude along. Default: 50
|
||||||
// d = Diameter of the spiral to extrude along.
|
|
||||||
// twist = number of degrees of rotation to spiral up along height.
|
// twist = number of degrees of rotation to spiral up along height.
|
||||||
|
// ---
|
||||||
|
// d = Diameter of the spiral to extrude along.
|
||||||
|
// higbee = Length to taper thread ends over.
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
|
||||||
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
|
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
|
||||||
|
@ -965,50 +967,57 @@ module extrude_from_to(pt1, pt2, convexity, twist, scale, slices) {
|
||||||
// Example:
|
// Example:
|
||||||
// poly = [[-10,0], [-3,-5], [3,-5], [10,0], [0,-30]];
|
// poly = [[-10,0], [-3,-5], [3,-5], [10,0], [0,-30]];
|
||||||
// spiral_sweep(poly, h=200, r=50, twist=1080, $fn=36);
|
// spiral_sweep(poly, h=200, r=50, twist=1080, $fn=36);
|
||||||
module spiral_sweep(poly, h, r, twist=360, center, d, anchor, spin=0, orient=UP) {
|
module spiral_sweep(poly, h, r, twist=360, higbee, center, r1, r2, d, d1, d2, higbee1, higbee2, anchor, spin=0, orient=UP) {
|
||||||
r = get_radius(r=r, d=d, dflt=50);
|
|
||||||
poly = path3d(poly);
|
poly = path3d(poly);
|
||||||
pline_count = len(poly);
|
|
||||||
steps = ceil(segs(r)*(twist/360));
|
|
||||||
anchor = get_anchor(anchor,center,BOT,BOT);
|
anchor = get_anchor(anchor,center,BOT,BOT);
|
||||||
|
r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=50);
|
||||||
|
r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=50);
|
||||||
|
sides = segs(max(r1,r2));
|
||||||
|
steps = ceil(sides*(twist/360));
|
||||||
|
higbee1 = first_defined([higbee1, higbee, 0]);
|
||||||
|
higbee2 = first_defined([higbee2, higbee, 0]);
|
||||||
|
higang1 = 360 * higbee1 / (2 * r1 * PI);
|
||||||
|
higang2 = 360 * higbee2 / (2 * r2 * PI);
|
||||||
|
higsteps1 = ceil(higang1/360*sides);
|
||||||
|
higsteps2 = ceil(higang2/360*sides);
|
||||||
|
assert(higang1 < twist/2);
|
||||||
|
assert(higang2 < twist/2);
|
||||||
|
|
||||||
poly_points = [
|
function higsize(a) = lookup(a,[
|
||||||
for (
|
[-0.001, 0],
|
||||||
p = [0:1:steps]
|
for (x=[0.125:0.125:1]) [ x*higang1, pow(x,1/2)],
|
||||||
) let (
|
for (x=[0.125:0.125:1]) [twist-x*higang2, pow(x,1/2)],
|
||||||
a = twist * (p/steps),
|
[twist+0.001, 0]
|
||||||
dx = r*cos(a),
|
]);
|
||||||
dy = r*sin(a),
|
|
||||||
dz = h * (p/steps),
|
us = [
|
||||||
mat = affine3d_translate([dx, dy, dz-h/2]) *
|
for (i=[0:higsteps1/10:higsteps1]) i,
|
||||||
affine3d_zrot(a) *
|
for (i=[higsteps1+1:1:steps-higsteps2-1]) i,
|
||||||
affine3d_xrot(90),
|
for (i=[steps-higsteps2:higsteps2/10:steps]) i,
|
||||||
|
];
|
||||||
|
zang = atan2(r2-r1,h);
|
||||||
|
points = [
|
||||||
|
for (p = us) let (
|
||||||
|
u = p / steps,
|
||||||
|
a = twist * u,
|
||||||
|
hsc = higsize(a),
|
||||||
|
r = lerp(r1,r2,u),
|
||||||
|
mat = affine3d_zrot(a) *
|
||||||
|
affine3d_translate([r, 0, h * (u-0.5)]) *
|
||||||
|
affine3d_xrot(90) *
|
||||||
|
affine3d_skew_xz(xa=zang) *
|
||||||
|
affine3d_scale([hsc,lerp(hsc,1,0.25),1]),
|
||||||
pts = apply(mat, poly)
|
pts = apply(mat, poly)
|
||||||
) for (pt = pts) pt
|
) pts
|
||||||
];
|
];
|
||||||
|
|
||||||
poly_faces = concat(
|
vnf = vnf_vertex_array(
|
||||||
[[for (b = [0:1:pline_count-1]) b]],
|
points, col_wrap=true, caps=true,
|
||||||
[
|
style=(abs(higbee1)+abs(higbee2))>0? "quincunx" : "alt"
|
||||||
for (
|
|
||||||
p = [0:1:steps-1],
|
|
||||||
b = [0:1:pline_count-1],
|
|
||||||
i = [0:1]
|
|
||||||
) let (
|
|
||||||
b2 = (b == pline_count-1)? 0 : b+1,
|
|
||||||
p0 = p * pline_count + b,
|
|
||||||
p1 = p * pline_count + b2,
|
|
||||||
p2 = (p+1) * pline_count + b2,
|
|
||||||
p3 = (p+1) * pline_count + b,
|
|
||||||
pt = (i==0)? [p0, p2, p1] : [p0, p3, p2]
|
|
||||||
) pt
|
|
||||||
],
|
|
||||||
[[for (b = [pline_count-1:-1:0]) b+(steps)*pline_count]]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
tri_faces = triangulate_faces(poly_points, poly_faces);
|
attachable(anchor,spin,orient, r1=r1, r2=r2, l=h) {
|
||||||
attachable(anchor,spin,orient, r=r, l=h) {
|
vnf_polyhedron(vnf, convexity=2*twist/360);
|
||||||
polyhedron(points=poly_points, faces=tri_faces, convexity=10);
|
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,19 +11,24 @@
|
||||||
|
|
||||||
// Module: thread_helix()
|
// Module: thread_helix()
|
||||||
// Usage:
|
// Usage:
|
||||||
// thread_helix(base_d, pitch, thread_depth, thread_angle, twist, [profile], [left_handed], [higbee], [internal]);
|
// thread_helix(d, pitch, thread_depth, <thread_angle>, <twist>, <profile=>, <left_handed=>, <higbee=>, <internal=>);
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a helical thread with optional end tapering.
|
// Creates a helical thread with optional end tapering.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// base_d = Inside base diameter of threads.
|
// d = Inside base diameter of threads. Default: 10
|
||||||
// pitch = Distance between threads.
|
// pitch = Distance between threads. Default: 2mm/thread
|
||||||
// thread_depth = Depth of threads from top to bottom.
|
// thread_depth = Depth of threads from top to bottom.
|
||||||
// thread_angle = Angle of the thread faces.
|
// thread_angle = Angle of the thread faces. Default: 15 degrees.
|
||||||
// twist = Number of degrees to rotate thread around.
|
// twist = Number of degrees to rotate thread around. Default: 720 degrees.
|
||||||
// profile = If a an asymmetrical thread profile is needed, it can be specified here.
|
// ---
|
||||||
|
// profile = If an asymmetrical thread profile is needed, it can be specified here.
|
||||||
// left_handed = If true, thread has a left-handed winding.
|
// left_handed = If true, thread has a left-handed winding.
|
||||||
// higbee = Angle to taper thread ends by.
|
|
||||||
// internal = If true, invert threads for internal threading.
|
// internal = If true, invert threads for internal threading.
|
||||||
|
// d1 = Bottom inside base diameter of threads.
|
||||||
|
// d2 = Top inside base diameter of threads.
|
||||||
|
// higbee = Length to taper thread ends over. Default: 0
|
||||||
|
// higbee1 = Length to taper bottom thread end over.
|
||||||
|
// higbee2 = Length to taper top thread end over.
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
|
||||||
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
|
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
|
||||||
|
@ -31,42 +36,44 @@
|
||||||
// pitch = 2;
|
// pitch = 2;
|
||||||
// depth = pitch * cos(30) * 5/8;
|
// depth = pitch * cos(30) * 5/8;
|
||||||
// profile = [
|
// profile = [
|
||||||
// [-7/16, -depth/pitch*1.07],
|
// [-6/16, 0 ],
|
||||||
// [-6/16, -depth/pitch],
|
// [-1/16, depth/pitch ],
|
||||||
// [-1/16, 0],
|
// [ 1/16, depth/pitch ],
|
||||||
// [ 1/16, 0],
|
// [ 6/16, 0 ],
|
||||||
// [ 6/16, -depth/pitch],
|
|
||||||
// [ 7/16, -depth/pitch*1.07]
|
|
||||||
// ];
|
// ];
|
||||||
// stroke(profile, width=0.02);
|
// stroke(profile, width=0.02);
|
||||||
module thread_helix(base_d, pitch, thread_depth=undef, thread_angle=15, twist=720, profile=undef, left_handed=false, higbee=60, internal=false, anchor=CENTER, spin=0, orient=UP)
|
// Example:
|
||||||
{
|
// thread_helix(d=10, pitch=2, thread_depth=0.75, thread_angle=15, twist=900, $fn=72);
|
||||||
|
module thread_helix(
|
||||||
|
d, pitch=2, thread_depth, thread_angle=15, twist=720,
|
||||||
|
profile, left_handed=false, internal=false,
|
||||||
|
d1, d2, higbee, higbee1, higbee2,
|
||||||
|
anchor=CENTER, spin=0, orient=UP
|
||||||
|
) {
|
||||||
h = pitch*twist/360;
|
h = pitch*twist/360;
|
||||||
r = base_d/2;
|
r1 = get_radius(d1=d1, d=d, dflt=10);
|
||||||
dz = thread_depth/pitch * tan(thread_angle);
|
r2 = get_radius(d1=d2, d=d, dflt=10);
|
||||||
|
tdp = thread_depth / pitch;
|
||||||
|
dz = tdp * tan(thread_angle);
|
||||||
cap = (1 - 2*dz)/2;
|
cap = (1 - 2*dz)/2;
|
||||||
profile = !is_undef(profile)? profile : (
|
profile = !is_undef(profile)? profile : (
|
||||||
internal? [
|
internal? [
|
||||||
[thread_depth/pitch, -cap/2-dz],
|
[-cap/2-dz, tdp],
|
||||||
[0, -cap/2],
|
[-cap/2, 0 ],
|
||||||
[0, +cap/2],
|
[+cap/2, 0 ],
|
||||||
[thread_depth/pitch, +cap/2+dz],
|
[+cap/2+dz, tdp],
|
||||||
] : [
|
] : [
|
||||||
[0, +cap/2+dz],
|
[+cap/2+dz, 0 ],
|
||||||
[thread_depth/pitch, +cap/2],
|
[+cap/2, tdp],
|
||||||
[thread_depth/pitch, -cap/2],
|
[-cap/2, tdp],
|
||||||
[0, -cap/2-dz],
|
[-cap/2-dz, 0 ],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
pline = profile * pitch;
|
pline = mirror([-1,1], p = profile * pitch);
|
||||||
dir = left_handed? -1 : 1;
|
dir = left_handed? -1 : 1;
|
||||||
idir = internal? -1 : 1;
|
idir = internal? -1 : 1;
|
||||||
attachable(anchor,spin,orient, r=r, l=h) {
|
attachable(anchor,spin,orient, r1=r1, r2=r2, l=h) {
|
||||||
difference() {
|
spiral_sweep(pline, h=h, r1=r1, r2=r2, twist=twist*dir, higbee=higbee, higbee1=higbee1, higbee2=higbee2, anchor=CENTER);
|
||||||
spiral_sweep(pline, h=h, r=base_d/2, twist=twist*dir, $fn=segs(base_d/2), anchor=CENTER);
|
|
||||||
down(h/2) right(r) right(internal? thread_depth : 0) zrot(higbee*dir*idir) fwd(dir*pitch/2) cube([3*thread_depth/cos(higbee), pitch, pitch], center=true);
|
|
||||||
up(h/2) zrot(twist*dir) right(r) right(internal? thread_depth : 0) zrot(-higbee*dir*idir) back(dir*pitch/2) cube([3*thread_depth/cos(higbee), pitch, pitch], center=true);
|
|
||||||
}
|
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +140,7 @@ module trapezoidal_threaded_rod(
|
||||||
left_handed=false,
|
left_handed=false,
|
||||||
bevel=false,
|
bevel=false,
|
||||||
starts=1,
|
starts=1,
|
||||||
profile=undef,
|
profile,
|
||||||
internal=false,
|
internal=false,
|
||||||
center, anchor, spin=0, orient=UP
|
center, anchor, spin=0, orient=UP
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,551];
|
BOSL_VERSION = [2,0,552];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue