For anybody who is interested, I have meanwhile published my nSpline()
function.
http://www.thingiverse.com/thing:1208001
http://forum.openscad.org/file/n15207/propeller.png
--
View this message in context: http://forum.openscad.org/Spline-interpolation-nSpline-tp15207.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
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:N-1])
// internal help variabel w = angle
let(w = i360/N)
// produce x and y
[rsin(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:N-1])
// internal help variabel w = angle
let(w = i360/(N-1))
// produce x and y
[rsin(w), rcos(w)]
];*
--
View this message in context: http://forum.openscad.org/Spline-interpolation-nSpline-tp15207p15354.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
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:N-1]) let(w = i360/N)
[rsin(w), r*cos(w)]];
function circle1_(r, N) = [
for(i=[0:N-1]) let(w = i360/(N-1))
[rsin(w), r*cos(w)]];
http://forum.openscad.org/file/n15355/showcase14.png
--
View this message in context: http://forum.openscad.org/Spline-interpolation-nSpline-tp15207p15355.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
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, 20-d, 0],
[20, 0,200, 40-d, -10],
[60, 0,300, 70-d, -60],
[68, 0,310, 100-d, -62],
[68+1.1,0,310+.7, 100-d, -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:N-1]) let(w = i360/N)
[rsin(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)];
--
View this message in context: http://forum.openscad.org/Spline-interpolation-nSpline-tp15207p15356.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
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()
https://github.com/openscad/list-comprehension-demos/blob/master/skin.scad
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 N-1-polygon only. To please
sweep(), skin() and the N-semantics:
function circle_(r, N) = [
for(i=[0:N]) let(w = i360/N)
[rsin(w), r*cos(w)]];
--
View this message in context: http://forum.openscad.org/Spline-interpolation-nSpline-tp15207p15361.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
btw: an example of the use of these functions is here:
http://forum.openscad.org/Parameterlist-Excel-export-to-OpenSCAD-td15363.html
http://forum.openscad.org/Parameterlist-Excel-export-to-OpenSCAD-td15363.html
--
View this message in context: http://forum.openscad.org/Spline-interpolation-nSpline-tp15207p15377.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I tried the sweep again with circles giving another small problem.
http://forum.openscad.org/file/n15392/bugsweep.jpg
This is the file I use:
curved_barrel_bes_clarinet_v4.scad
http://forum.openscad.org/file/n15392/curved_barrel_bes_clarinet_v4.scad
I also tried this with skin.
Resulting in this messags:
/Saved backup file: C:/Users/Eigenaar/Documents/OpenSCAD/backups/curved
barrel bes clarinet v3-backup-mpfy1924.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/
--
View this message in context: http://forum.openscad.org/Spline-interpolation-nSpline-tp15207p15392.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
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
--
View this message in context: http://forum.openscad.org/Spline-interpolation-nSpline-tp15207p15393.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Hi Rudolf, no problem.
But I think I miss some essential libs for skin to work.
--
View this message in context: http://forum.openscad.org/Spline-interpolation-nSpline-tp15207p15394.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Try this link: https://github.com/openscad/scad-utils
--
View this message in context: http://forum.openscad.org/Spline-interpolation-nSpline-tp15207p15397.html
Sent from the OpenSCAD mailing list archive at Nabble.com.