Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. airfoildata = Drop[Take[
  2. Drop[
  3. Import["n64015.dat"], 3], 53], {27}];
  4. airfoildata = Join[Reverse[Drop[Take[airfoildata, 26], 1]],
  5. Drop[airfoildata, 26]];
  6.  
  7. pts = Take[airfoildata, 20];
  8. n = Length[pts];
  9. dist = Accumulate[
  10. Table[EuclideanDistance[pts[[i]], pts[[i + 1]]], {i, Length[pts] - 1}]];
  11. param = N[Prepend[dist/Last[dist], 0]];
  12. deg = 3;
  13. knots = Join[ConstantArray[0, deg], Range[0, 1, 1/(n - deg)],
  14. ConstantArray[1, deg]];
  15. m = Table[BSplineBasis[{deg, knots}, j - 1, param[[i]]], {i, n}, {j, n}];
  16. ctrlpts = LinearSolve[m, pts];
  17.  
  18. ListPlot[airfoildata, Prolog -> BSplineCurve[ctrlpts],
  19. PlotStyle -> Directive[Red, PointSize[Medium]]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement