mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Fix short taper bug for spiral_sweep()
Doc fixes
This commit is contained in:
parent
d3836b9bc3
commit
2a98374ef1
3 changed files with 20 additions and 9 deletions
|
@ -101,7 +101,7 @@ function lerp(a,b,u) =
|
||||||
// Description:
|
// Description:
|
||||||
// Returns exactly `n` values, linearly interpolated between `a` and `b`.
|
// Returns exactly `n` values, linearly interpolated between `a` and `b`.
|
||||||
// If `endpoint` is true, then the last value will exactly equal `b`.
|
// If `endpoint` is true, then the last value will exactly equal `b`.
|
||||||
// If `endpoint` is false, then the last value will about `a+(b-a)*(1-1/n)`.
|
// If `endpoint` is false, then the last value will be `a+(b-a)*(1-1/n)`.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// a = First value or vector.
|
// a = First value or vector.
|
||||||
// b = Second value or vector.
|
// b = Second value or vector.
|
||||||
|
|
19
skin.scad
19
skin.scad
|
@ -1026,6 +1026,8 @@ module rotate_sweep(
|
||||||
function _taperfunc(x) =
|
function _taperfunc(x) =
|
||||||
let(higofs = pow(0.05,2)) // Smallest hig scale is the square root of this value
|
let(higofs = pow(0.05,2)) // Smallest hig scale is the square root of this value
|
||||||
sqrt((1-higofs)*x+higofs);
|
sqrt((1-higofs)*x+higofs);
|
||||||
|
function _taperfunc(x) =
|
||||||
|
sqrt(1-(1-x)^2);
|
||||||
function _ss_polygon_r(N,theta) =
|
function _ss_polygon_r(N,theta) =
|
||||||
let( alpha = 360/N )
|
let( alpha = 360/N )
|
||||||
cos(alpha/2)/(cos(posmod(theta,alpha)-alpha/2));
|
cos(alpha/2)/(cos(posmod(theta,alpha)-alpha/2));
|
||||||
|
@ -1045,7 +1047,7 @@ function spiral_sweep(poly, h, r, turns=1, higbee, center, r1, r2, d, d1, d2, hi
|
||||||
sides = segs(max(r1,r2)),
|
sides = segs(max(r1,r2)),
|
||||||
dir = sign(twist),
|
dir = sign(twist),
|
||||||
ang_step = 360/sides*dir,
|
ang_step = 360/sides*dir,
|
||||||
anglist = [for(ang = [0:ang_step:twist-EPSILON]) ang,
|
orig_anglist = [for(ang = [0:ang_step:twist-EPSILON]) ang,
|
||||||
twist],
|
twist],
|
||||||
higbee1 = first_defined([higbee1, higbee, 0]),
|
higbee1 = first_defined([higbee1, higbee, 0]),
|
||||||
higbee2 = first_defined([higbee2, higbee, 0]),
|
higbee2 = first_defined([higbee2, higbee, 0]),
|
||||||
|
@ -1056,11 +1058,20 @@ function spiral_sweep(poly, h, r, turns=1, higbee, center, r1, r2, d, d1, d2, hi
|
||||||
assert(higang1 < dir*twist/2,"Higbee1 is more than half the threads")
|
assert(higang1 < dir*twist/2,"Higbee1 is more than half the threads")
|
||||||
assert(higang2 < dir*twist/2,"Higbee2 is more than half the threads")
|
assert(higang2 < dir*twist/2,"Higbee2 is more than half the threads")
|
||||||
let(
|
let(
|
||||||
|
// This complicated sampling scheme is designed to ensure that there is always a facet boundary
|
||||||
|
// at the $fn specified location, regardless of what kind of subsampling occurs for tapers."
|
||||||
|
anglist = [
|
||||||
|
for(a=orig_anglist) if (a*dir<higang1-EPSILON) a,
|
||||||
|
dir*higang1,
|
||||||
|
for(a=orig_anglist) if (a*dir>higang1+EPSILON && (twist-a)*dir>higang2+EPSILON) a,
|
||||||
|
twist-dir*higang2,
|
||||||
|
for(a=orig_anglist) if ((twist-a)*dir<higang2-EPSILON) a
|
||||||
|
],
|
||||||
interp_ang = [
|
interp_ang = [
|
||||||
for(i=idx(anglist,e=-2))
|
for(i=idx(anglist,e=-2))
|
||||||
each lerpn(anglist[i],anglist[i+1],
|
each lerpn(anglist[i],anglist[i+1],
|
||||||
(higang1>0 && higang1>dir*anglist[i+1]
|
(higang1>0 && dir*anglist[i+1]<=higang1) || (higang2>0 && dir*(twist-anglist[i])<=higang2)
|
||||||
|| (higang2>0 && higang2>dir*(twist-anglist[i]))) ? ceil((anglist[i+1]-anglist[i])/ang_step*higsample)
|
? ceil((anglist[i+1]-anglist[i])/ang_step*higsample)
|
||||||
: 1,
|
: 1,
|
||||||
endpoint=false),
|
endpoint=false),
|
||||||
last(anglist)
|
last(anglist)
|
||||||
|
@ -1082,7 +1093,7 @@ function spiral_sweep(poly, h, r, turns=1, higbee, center, r1, r2, d, d1, d2, hi
|
||||||
) pts
|
) pts
|
||||||
],
|
],
|
||||||
vnf = vnf_vertex_array(
|
vnf = vnf_vertex_array(
|
||||||
points, col_wrap=true, caps=true, reverse=dir>0?true:false,
|
points, col_wrap=true, caps=true, reverse=dir>0,
|
||||||
// style=higbee1>0 || higbee2>0 ? "quincunx" : "alt"
|
// style=higbee1>0 || higbee2>0 ? "quincunx" : "alt"
|
||||||
style="convex"
|
style="convex"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// LibFile: vectors.scad
|
// LibFile: vectors.scad
|
||||||
// This file provides some mathematical operations that apply to each
|
// This file provides some mathematical operations that apply to each
|
||||||
// entry in a vector. It provides normalizatoin and angle computation, and
|
// entry in a vector. It provides normalization and angle computation, and
|
||||||
// it provides functions for searching lists of vectors for matches to
|
// it provides functions for searching lists of vectors for matches to
|
||||||
// a given vector.
|
// a given vector.
|
||||||
// Includes:
|
// Includes:
|
||||||
|
|
Loading…
Reference in a new issue