smooth spline through airfoil coordinates
After permuting the points so that the cusp is the first point (just like in Gypaets's answer), the methods of this answer can be used:
airfoil = Flatten[MapAt[Most @* Reverse, DeleteCases[Split[Drop[
Import["http://m-selig.ae.illinois.edu/ads/coord/n64015.dat"], 3],
# =!= {} && #2 =!= {} &], {{}}], 1], 1];
(* Lee's method, http://dx.doi.org/10.1016/0010-4485(89)90003-1 *)
parametrizeCurve[pts_List, a : (_?NumericQ) : 1/2] :=
FoldList[Plus, 0, Normalize[(Norm /@ Differences[pts])^a, Total]] /;
MatrixQ[pts, NumericQ]
tvals = parametrizeCurve[airfoil];
m = 3; (* degree of the B-spline *)
(* knots for interpolating B-spline *)
knots = Join[ConstantArray[0, m + 1], MovingAverage[ArrayPad[tvals, -1], m],
ConstantArray[1, m + 1]];
(* basis function matrix *)
bas = Table[BSplineBasis[{m, knots}, j - 1, tvals[[i]]],
{i, Length[airfoil]}, {j, Length[airfoil]}];
ctrlpts = LinearSolve[bas, airfoil];
Graphics[{{Directive[AbsoluteThickness[3], ColorData[97, 1]],
BSplineCurve[ctrlpts, SplineDegree -> 3, SplineKnots -> knots]},
{AbsolutePointSize[5], Point[airfoil]}}, Axes -> None, Frame -> True]
Replace BSplineCurve[]
with BSplineFunction[]
if needed.
In an airfoil you probably want a sharp trailing edge and a rounded leading edge. Therefore I would choose the trailing edge as first and last point for your spline:
path = "http://m-selig.ae.illinois.edu/ads/coord/n64015.dat";
airfoilData = Drop[Take[Drop[Import@path,3], 53], {27}];
upperSide = airfoilData[[1 ;; Length@airfoilData/2]];
lowerSide = airfoilData[[Length@airfoilData/2 + 1 ;; -1]];
airfoilDataOrdered = Reverse@upperSide~Join~lowerSide[[2 ;; -1]];
Create spline:
f = BSplineFunction[airfoilDataOrdered];
Plot:
ListPlot[{airfoilDataOrdered, f /@ Range[0, 1, 0.01]}]
EDIT 1
To go through the points you can do a parametric interpolation.
f2 = Interpolation[Table[{i, airfoilDataOrdered[[i]]}, {i, Length@airfoilDataOrdered}],
Method -> "Spline", InterpolationOrder -> 5];
ParametricPlot[f2[x], {x, 1, Length@airfoilDataOrdered},
PlotRange -> {{0, 0.03}, {-0.03, 0.03}}]
The nose should now be ok.
EDIT 2
Polar approach:
iPoints =
Table[{π - ArcTan[-airfoilDataOrdered[[i, 1]] + 1/4, airfoilDataOrdered[[i, 2]]],
airfoilDataOrdered[[i]] - {1/4, 0}}, {i, Length@airfoilDataOrdered}];
iPoints[[-1, 1]] = 2 π;
f3 = Interpolation[iPoints, Method -> "Spline", InterpolationOrder -> 2];
ParametricPlot[f3[x], {x, 0, 2 π}, PlotRange -> All]