
1234

For the purpose of the Frenet sweep only, you may use:
function subdivBezier3_2(p, n=4) = (p[i]+(2*p[i1]/3 + p[i+2]/3))/2 : (p[i]+(p[i2]/3 + 2*p[i+1]/3))/2 ] let( seq = [for(i=[0:3:len(p)4], s=_subdivB(p,i)) s ] ) subdivBezier3_2( concat( [ p[0] ], seq ), n1);
It eliminates collinearities but its output will not be appropriate to BzEnergy() digestion.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


As I have supposed the instability was produced by BestBz(). I had to tighten the stopping clause in _bestS to get a better stability. I can't assure this method is foolproof; it may go wild when the tangent directions and endpoints induce a loop or inflexions to the arc. Besides, to avoid stack overflow I limited arbitrarily the maximum number of recursions calls.
function _bestS(bz, l, s1, s2, e1, e2, eps=1e3, n=15) = e12 = BalancedEnergy(bz, s12, l, eps), s3 = max(min(parabMin(s1,s12,s2,e1,e12,e2),1eps),eps),
e3 = BalancedEnergy(bz, s3, l, eps) ) //echo(s1=s1,s3=s3,s12=s12,s2=s2,e1=e1,e3=e3,e12=e12,e2=e2,n=n) (abs(e3e12)/e12<eps && abs(s3s12)<eps)  n==0 ? // * main change * _bestS(bz,l,s1,s12,e1,e12,eps,n1) _bestS(bz,l,s12,s2,e12,e2,eps,n1) _bestS(bz,l,s3,s2,e3,e2,eps,n1) _bestS(bz,l,s1,s3,e1,e3,eps,n1);
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

1234
