Plotting "airfoil" to foam-machine

A couple of days ago I asked how I could draw a SMOOTH line trough a couple of points, and I got 2 answers:
-B-spline who cuts corners until the line is smooth (so the line doesn't go though the points)
-Cubic-spline cut draws a lot of separate functions of the seconds order (a*x**2 + b*x + c) which means that the second derivate has jumps in it. For airfoils this is unacceptable because the 2nd derivate should be smooth too so that the air going arround it would be laminar.

The B-spline is smooth enough, but doesn't GO THROUGH the given points, which means our airfoils changes. (=unacceptable when you are looking for performance)
The second one is not smooth enough.

Does anyone know an algorithm that draws a line that is as smooth as the B-spline and still GOES THROUGH the given points (which are in line)

I have built a foam-cutting machine which is computer controlled. Now I just  need to draw this SMOOTH line through a series of 15 to 100 points. Out of these 15 to 100 points I should compute about 500 to 1000 points to match the foan-cutters accurancy (2 points mm)

There are some software (freeware) on the web like WINFOIL and others who do the job for a regular printer, so it should not be so difficult. (only they don't give there codes away)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hello... did you read the link i gave last time?

cubic spline uses cubic curves, not quadratics, so S''(x) can be continuous (ie. no jumps)
de_wagterAuthor Commented:
yes, I read the link completely.

I tried it out in mathcad and it worked great for functions like a sinus or others, but when you enter points that are nearly on a straight line or nearly straight line, then the result is NOT STRAIGHT but "WAVE-like", whereelse it should be as STRAIGHT  AS POSSIBLE.

Your link looked very interesting, thats why i remember accepting your comment as an answer, but I'm not sure it's usefull for drawing airfoils. (maybe I'm wrong, so please help me) (maybe the cubic spline in mathcad is not shown as good as in mathlab...i already noticed that some graphics are not so good in mathcad 7.0)

At this slide:
It says indeed the 2nd derivate is continuous, and that should indeed be enough for the airfoil to be good.

But when you look at drwings like:
this line is realy not STRAIGHT.

How do I get it STRAIGHT?

Thanx for helping
you could try parametric cubic interpolation, but it requires more control parameters; at least that's what i think what i read said...: check out Catmull-Rom, Hermite, Bezier, cardinal splines

this link:

has a sort of summary for parametric cubic thingos...

I think this really boils down to the question of what you mean by the word 'jumps'.
If you expect the second derivative to be smooth in the sense of showing a rounded, rather than linear, shape on plotting, you have to resort to higher order functions than cubics.
If however it is enough that your second order derivative is simply continous and consists of linear segments between individual points, you might be able to use the following formulae which I once wrote a little article about. These are written in the assumption that each segment is a function y of x, i.e. only one y value per x value. If that is sufficient then you should be OK.

Hope this helps ...

The parameters of the cubic can be derived from four simultaneous equations :

  y1 = a*(x1)^3 + b*(x1)^2 + c*(x1) + d
  y2 = a*(x2)^3 + b*(x2)^2 + c*(x2) + d

  g1 = a*(x1)^2 + b*(x1) + c
  g2 = a*(x2)^2 + b*(x2) + c

  ... where (x1,y1) are the co-ordinates of point 1,
            (x2,y2) are the co-ordinates of point 2,
            g1 is the gradient at point 1, and
            g2 is the gradient at point 2.

After a sheet of A4 full of mental scribbling you'd arrive at the following :

  a=( 2*(y1-y3)*(x1-x3) - (g1-g2)*(sqr(x1)-sqr(x3)-2*x1*(x1-x3))
      -2*g1*(x1-x3)*(x1-x3) ) / ( 2*(x1*x1*x1-x3*x3*x3
  b=( g1-g2-3*a*(sqr(x1)-sqr(x3)) ) / ( 2*(x1-x3) )

Now use a,b,c and d in the general cubic y=a*x^3 + b*x^2 + c*x + d.
Loop through the cubic with different values of x, get a smooth path
.... and enjoy.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
de_wagterAuthor Commented:
It took me some time to check the result, but it is perfect. I don't know why MAtchCAD draws those c-splines so bad, because with pascal the result is perfect.

As to lychee, you were right about those c-splines. Sorry for asking the same question again, but I was just disappointed by the result I found in MatchCAD that night. It made me think the lines were not good enough.
I probably just was too lazy to do this "sheet of A4 full of mental scribbling".... :-)

Thanks to both of you.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.