From 6ef2f712550c8fa9c715fda5419e4ebce2e5ff79 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Sat, 28 Aug 2021 08:57:09 -0400 Subject: [PATCH] improved thread_helix docs fixed bugs in spiral_sweep: wrong sampling rate, left_handed broken --- paths.scad | 28 +++++++++++++++------------- threading.scad | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/paths.scad b/paths.scad index c661f62..30ec5eb 100644 --- a/paths.scad +++ b/paths.scad @@ -1055,7 +1055,7 @@ module extrude_from_to(pt1, pt2, convexity, twist, scale, slices) { // spiral_sweep(poly, h=200, r=50, twist=1080, $fn=36); module spiral_sweep(poly, h, r, twist=360, higbee, center, r1, r2, d, d1, d2, higbee1, higbee2, internal=false, anchor, spin=0, orient=UP) { higsample = 10; // Oversample factor for higbee tapering - dummy1=assert(twist>0); +// dummy1=assert(twist>0); bounds = pointlist_bounds(poly); yctr = (bounds[0].y+bounds[1].y)/2; xmin = bounds[0].x; @@ -1065,7 +1065,8 @@ module spiral_sweep(poly, h, r, twist=360, higbee, center, r1, r2, d, d1, d2, hi 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)); - ang_step = 360/sides; + dir = sign(twist); + ang_step = 360/sides*dir; anglist = [for(ang = [0:ang_step:twist-EPSILON]) ang, twist]; higbee1 = first_defined([higbee1, higbee, 0]); @@ -1073,23 +1074,24 @@ module spiral_sweep(poly, h, r, twist=360, higbee, center, r1, r2, d, d1, d2, hi higang1 = 360 * higbee1 / (2 * r1 * PI); higang2 = 360 * higbee2 / (2 * r2 * PI); dummy2=assert(higbee1>=0 && higbee2>=0) - assert(higang1 < twist/2) - assert(higang2 < twist/2); + assert(higang1 < dir*twist/2) + assert(higang2 < dir*twist/2); function polygon_r(N,theta) = let( alpha = 360/N ) cos(alpha/2)/(cos(posmod(theta,alpha)-alpha/2)); function higsize(a) = lookup(a,[ - [-0.001, higang1>0?0:1], - if (higang1>0) for (x=[0.125:0.125:1]) [ x*higang1, pow(x,1/2)], - if (higang2>0) for (x=[0.125:0.125:1]) [twist-x*higang2, pow(x,1/2)], - [twist+0.001, higang2>0?0:1] + [-0.001*dir, higang1>0?0:1], + if (higang1>0) for (x=[0.125:0.125:1]) [ dir*x*higang1, pow(x,1/2)], + if (higang2>0) for (x=[0.125:0.125:1]) [twist-dir*x*higang2, pow(x,1/2)], + [twist+dir*0.001, higang2>0?0:1] ]); - + interp_ang = [ for(i=idx(anglist,e=-2)) each lerpn(anglist[i],anglist[i+1], - (higang1anglist[i])) ? ceil((anglist[i+1]-anglist[i])/ang_step*higsample) - : 1, + (higang1>0 && higang1>dir*anglist[i+1] + || (higang2>0 && higang2>dir*(twist-anglist[i]))) ? ceil((anglist[i+1]-anglist[i])/ang_step*higsample) + : 1, endpoint=false), last(anglist) ]; @@ -1110,12 +1112,12 @@ module spiral_sweep(poly, h, r, twist=360, higbee, center, r1, r2, d, d1, d2, hi ]; vnf = vnf_vertex_array( - points, col_wrap=true, caps=true, reverse=true, + points, col_wrap=true, caps=true, reverse=dir>0?true:false, style=higbee1>0 || higbee2>0 ? "quincunx" : "alt" ); attachable(anchor,spin,orient, r1=r1, r2=r2, l=h) { - vnf_polyhedron(vnf, convexity=ceil(2*twist/360)); + vnf_polyhedron(vnf, convexity=ceil(2*dir*twist/360)); children(); } } diff --git a/threading.scad b/threading.scad index 0a2cf8b..1f8bab1 100644 --- a/threading.scad +++ b/threading.scad @@ -1093,14 +1093,23 @@ module generic_threaded_nut( // Description: // Creates a right-handed helical thread with optional end tapering. Unlike generic_threaded_rod, this module just generates the thread, and // you specify the angle of thread you want, which makes it easy to put complete threads onto a longer shaft. It also makes a more finely -// divided taper at the thread ends. However, if you use it for large length of thread it is much slower than generic_threaded_rod. +// divided taper at the thread ends. However, it takes about twice as long to render compared to generic_threaded_rod. // . // You can specify a thread_depth and flank_angle, in which -// case you get a symmetric trapezoidal thread, whose base is at the diameter (so the total diameter will be d + thread_depth). -// Atlernatively you can give a profile, following the same rules as for general_threaded_rod. +// case you get a symmetric trapezoidal thread, whose inner diameter (the base of the threads for external threading) +// is d (so the total diameter will be d + thread_depth). This differs from the threaded_rod modules, where the specified +// diameter is the outer diameter. +// Alternatively you can give a profile, following the same rules as for general_threaded_rod. // The Y=0 point will align with the specified diameter, and the profile should // range in X from -1/2 to 1/2. You cannot specify both the profile and the thread_depth or flank_angle. // . +// Unlike generic_threaded_rod, when internal=true this module generates the threads, not a thread mask. +// The profile needs to be inverted to produce the proper thread form. If you use the built-in trapezoidal +// thread you get the inverted thread, designed so that the inner diameter is d. With adequate clearance +// this thread will mate with the thread that uses the same parameters but has internal=false. Note that +// unlike the threaded_rod modules, thread_helix does not adjust the diameter for faceting, nor does it +// subtract any $slop for clearance. +// . // Higbee specifies tapering applied to the ends of the threads and is given as the linear distance // over which to taper. // Arguments: @@ -1134,6 +1143,9 @@ module generic_threaded_nut( // stroke(profile, width=0.02); // Example: // thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, twist=900, $fn=72); +// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, twist=900, higbee=1, $fn=72); +// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, twist=720, higbee=2, internal=true, $fn=72); +// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, twist=360, left_handed=true, higbee=1, $fn=36); module thread_helix( d, pitch, thread_depth, flank_angle, twist=720, profile, starts=1, left_handed=false, internal=false,