I think that's a bug in the routine. In the interpolation inside the loft,
the weights are computed as (i-1)/(len(p)-1), that should really be
(i-1)/(len(p)-2) - loft internally adds an extra unused point to the path to
get a value for the last tangent...
Thanks for finding this.
Of course sweep() cannot check for self intersection with respect to runtime.
Also interpolation schemes are prone to produce self intersection.
Btw. I wouldn't model the two techniques (interpolation and sweep) into a
single scheme. There are several steps involved, which can be implemented in
a more general fashion to get a more general scheme.
1. define some resampling function to unify the # of vertices (not needed if
skin() is used)
2. define an interpolation function that interpolates between the two
polygons according to some value k between 0 and 1.
3. use a composer function to model the extrusion trajectory (the final
4. use any sweep() for the dirty work (e.g. my Naca_sweep lib)
while 3) is the function that does the final shape, and 4) is library stuff,
1) and 2) are simply:
example($t); // set up an animation to view the interpolation
module example(k=.4, n=3, N=120)
p = interpol(circle(r=5, N=N), resample(circle(N=n), N/n), k);