I am trying to produce a smooth spline curve through a set of airfoil coordinates. An example for the data I am trying to use is here, and I am reading the file like so to get rid of some extraneous stuff:
airfoildata = Drop[Take[
Drop[
Import["n64015.dat"], 3], 53], {27}];
airfoildata = Join[Reverse[Drop[Take[airfoildata, 26], 1]],
Drop[airfoildata, 26]];
ListLinePlot gives a plot of the airfoil that's alright, but you can see some "kinks" in the plot near the leading edge, where data are sparse relative to the curvature. So, I tried getting a real smooth curve via B-Splines, using this code:
pts = Take[airfoildata, 20];
n = Length[pts];
dist = Accumulate[
Table[EuclideanDistance[pts[[i]], pts[[i + 1]]], {i, Length[pts] - 1}]];
param = N[Prepend[dist/Last[dist], 0]];
deg = 3;
knots = Join[ConstantArray[0, deg], Range[0, 1, 1/(n - deg)],
ConstantArray[1, deg]];
m = Table[BSplineBasis[{deg, knots}, j - 1, param[[i]]], {i, n}, {j, n}];
ctrlpts = LinearSolve[m, pts];
and then plotting it via
ListPlot[airfoildata, Prolog -> BSplineCurve[ctrlpts],
PlotStyle -> Directive[Red, PointSize[Medium]]]
Using only the first 20 points as in the above code fragment, things look good, but if I use 21 points I can see numerical instability creeping in, for 22 points things get truly awful, and beyond that the linear system for the control points has no solution.
So here's my question: How can I obtain a smooth curve (with a nicely rounded leading edge near the origin) that respects the given airfoil coordinates? It looks like a standard B-spline will not work, and somehow this seems to be related to the fact that I have a relatively large number of points. However, I have used various CAD packages in the past that had no problems creating a smooth curve through data like the ones I have.