Advertisement
Matthen

Walker Attractor

Feb 17th, 2015
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. map[{u_, v_}] := {1, 1} - v {Sin[Pi u/2], Cos[Pi u/2]};
  2. pts = RandomReal[{0, 1}, {1000, 2}];
  3. n = 2000;
  4. squares = Table[
  5. pts = N@Join[
  6. s Table[{0, t/n} , {t, 0, n}],
  7. s Table[{ t/n, 1}, {t, 0, n}],
  8. s Table[{1, 1 - t/n}, {t, 0, n}],
  9. s Table[{1 - t/n, 0}, {t, 0, n}]
  10. ];
  11. Map[# + (1 - s) {1, 1}/2 &, pts],
  12. {s, 0.1, 1, 0.1}];
  13. f[pts_] := Map[map, pts];
  14. ptsLists = Table[NestList[f, pts, 20], {pts, squares}];
  15. frame[i_] :=
  16. With[{\[Iota] = If[i < 5,
  17. If[i == 0, 0,
  18. 1 + Sum[0.5 + 0.5 Tanh[5 (i - j - 0.5)], {j, 5}]],
  19. 5 + (i - 5)^1.5]},
  20. Graphics[{
  21. EdgeForm[],
  22. Table[
  23. Module[{ps},
  24. ps =
  25. ptsLists[[j, Floor@\[Iota]]] (1 - Mod[\[Iota], 1]) +
  26. ptsLists[[j, Floor@\[Iota] + 1]] Mod[\[Iota], 1];
  27. ps =
  28. Map[(# - {0.5, 0.5}) (0.7 + 0.3 (1 - Cos[2 Pi \[Iota]])/2) &,
  29. ps];
  30. {
  31. FaceForm[ColorData["RedBlueTones"][j/Length@squares]],
  32. Polygon[ps.RotationMatrix[Pi \[Iota]/2]]
  33. }
  34. ]
  35. , {j, Length@squares, 1, -1}]
  36. },
  37. PlotRange -> 0.5
  38. ]
  39. ];
  40. frames = Table[frame[i], {i, 1, 11.1, 11.1/87}];
  41. Export["walker.gif", frames]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement