

Hello Parkinbod,
very interesting. I spend some time on finding how interpolation works and begin to understand what you are doing. However there is a small bug in your horn file causing an unfinished circle:
function circle_(r, N) =
[ // input: radius r and the number of vectors
// output: N vectors on edge of circle with radius r
for(i=[0:N1])
// internal help variabel w = angle
let(w = i*360/N)
// produce x and y
[r*sin(w), r*cos(w)]
];
this should be:
function circle_(r, N) =
[ // input: radius r and the number of vectors
// output: N vectors on edge of circle with radius r
for(i=[0:N1])
// internal help variabel w = angle
let(w = i*360/(N1))
// produce x and y
[r*sin(w), r*cos(w)]
];


Thanks for looking at the code. I don't see a bug, as polygon() closes a figure itself. Both versions seem to work, but yours produces the initial point twice  don't know whether polygon treats this case internally. But let's see what happens:
difference()
{
polygon(points = circle_(6, 5));
polygon(points = circle1_(3, 5));
}
function circle_(r, N) = [
for(i=[0:N1]) let(w = i*360/N)
[r*sin(w), r*cos(w)]];
function circle1_(r, N) = [
for(i=[0:N1]) let(w = i*360/(N1))
[r*sin(w), r*cos(w)]];


This post was updated on .
Try this one:
////////////////////////////////////////////////////
// horn.scad  demo for mulivariate splines
// Implementation: Rudolf Huttary (c), Berlin
// Dezember 2015
// commercial use prohibited
use <splines.scad> use <Naca_sweep.scad>
A = [//x, y,z, r, angle // data outer skin
[0, 0,0, 20, 0],
[20, 0,200, 40, 10],
[60, 0,300, 70, 60],
[68, 0,310, 100, 62],
[68+1,0,310+.6, 100, 62],
];
d = 1; // thickness
A1 = [ // data inner skin
[0.001,0,0.001, 20d, 0],
[20, 0,200, 40d, 10],
[60, 0,300, 70d, 60],
[68, 0,310, 100d, 62],
[68+1.1,0,310+.7, 100d, 62],
];
B = nSpline(A,20); // outer skin
B1 = nSpline(A1,20); // inner skin
C = gen_dat(B, 80); // generate data
C1 = gen_dat(B1, 80); // generate data
difference()
{
sweep(C);
sweep(C1);
}
function circle_(r, N) = [
for(i=[0:N1]) let(w = i*360/N)
[r*sin(w), r*cos(w)]];
function gen_dat(S, N) =
[ for (i=[0:len(S)1])
let(dat = Ry_(S[i][4], vec3D(circle_(S[i][3], N))))
T_(S[i][0], S[i][1], S[i][2], dat)];


Ah, good point!
Thanks for putting me on the right track! It is not the circle, but some strange habit of my sweep() function, which doesn't close polygons itself. I should give it a review some day to also work with standard semantics.
As expected the equivalent function skin() works correctly with both versions:
use <splines.scad> use <Naca_sweep.scad>
use <skin.scad>
A = [//x, y,z, r, angle // data outer skin
[0, 0,0, 20, 0],
...
difference()
{
skin(C);
skin(C1);
}
Your version seems to work with both, but does a N1polygon only. To please sweep(), skin() and the Nsemantics:
function circle_(r, N) = [
for(i=[0:N]) let(w = i*360/N)
[r*sin(w), r*cos(w)]];


I tried the sweep again with circles giving another small problem.
This is the file I use:
curved_barrel_bes_clarinet_v4.scadI also tried this with skin.
Resulting in this messags:
Saved backup file: C:/Users/Eigenaar/Documents/OpenSCAD/backups/curved barrel bes clarinet v3backupmpfy1924.scad
Compiling design (CSG Tree generation)...
ECHO: "l_barrel", 60.9279
ECHO: "len", 100
WARNING: Ignoring unknown function 'to_3d'.
ERROR: Recursion detected calling function 'len'
Compiling design (CSG Products generation)...
Geometries in cache: 270
Geometry cache size in bytes: 23560776
CGAL Polyhedrons in cache: 15
CGAL cache size in bytes: 38279532
Compiling design (CSG Products normalization)...
Normalized CSG tree has 0 elements
Compile and preview finished.
Total rendering time: 0 hours, 0 minutes, 0 seconds


Thanks again for producing test cases. I haven't had time to revise the code.
But skin() works with me. It includes some more libs, which should be in the path ... This will solve your problem
 Rudolf


Hi Rudolf, no problem.
But I think I miss some essential libs for skin to work.


From my experiments, it doesn't matter if the start point is defined once or twice.
Larry


Hi Johan,
I just updated sweep() and it fits your needs now. You can download it from http://www.thingiverse.com/thing:1208001BTW sweep() is NOT a full blown algorithm you can use with any shape. It consumes convex shapes and weakly symmetric shapes like airfoils only, but NO fancy stuff. skin() has a more general implementation.
Don't forget to use the proper version of circle_() now.
function circle_(r, N) = [ for(i=[0:N1]) let(angle = i*360/N) [r*sin(angle), r*cos(angle)]];
 Rudolf


This post was updated on .
Hi Parkinbot,
Sorry for my very late reaction. I was very busy with a lot of things. But today I again encountered the small bugs with your earlier version of sweep and thought: maybe Parkinbot has already made a new version. And YES, that is the case! And is it working perfect now!
Many thanks for that!!
kind regards Johan

