Advertisement
Matthen

Harriss Spiral

Feb 6th, 2015
1,127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. ps = {
  2. {True, {0, 0}, 0, 1}
  3. };
  4. n = 6;
  5. \[Phi] = N[
  6. 1/3 (27/2 - (3 Sqrt[69])/2)^(1/3) + (1/2 (9 + Sqrt[69]))^(1/3)/3^(
  7. 2/3)];
  8. split[p_] := Module[{centre, \[Theta], scale},
  9. {centre, \[Theta], scale} = p[[2 ;;]];
  10. {
  11. {True,
  12. centre -
  13. scale RotationMatrix[\[Theta]].{1/(2 \[Phi]^2), 0}, \[Theta] +
  14. Pi/2, scale/\[Phi]},
  15. {True,
  16. centre +
  17. scale RotationMatrix[\[Theta]].{1/(2 \[Phi]),
  18. 1/(2 \[Phi]^2)}, \[Theta], scale/(\[Phi]^3)},
  19. {False,
  20. centre +
  21. scale RotationMatrix[\[Theta]].{1/(2 \[Phi]), -1/(2 \[Phi]^3)}, \
  22. \[Theta] - Pi/2, scale/\[Phi]^2}
  23. }
  24. ];
  25. nextgen[ps_] := Flatten[Map[split,
  26. Select[ps, First]
  27. ], 1];
  28. allps = Flatten[NestList[nextgen, ps, n], 1];
  29. graphic[p_] := Module[{centre, \[Theta], scale, w, bl, tr},
  30. {centre, \[Theta], scale} = p[[2 ;;]];
  31. If[First[p],
  32. bl = centre - scale RotationMatrix[\[Theta]].{\[Phi], 1}/2;
  33. tr = centre + scale RotationMatrix[\[Theta]].{\[Phi], 1}/2;
  34. Rectangle[bl, tr],
  35. bl = centre - scale RotationMatrix[\[Theta]].{1, 1}/2;
  36. tr = centre + scale RotationMatrix[\[Theta]].{1, 1}/2;
  37. Rectangle[bl, tr]
  38. ]
  39. ];
  40. arcs[p_] := Function[{t},
  41. Module[{centre, \[Theta], scale, out = {}},
  42. {centre, \[Theta], scale} = p[[2 ;;]];
  43. out = {
  44. Thickness[Max[0.001, 0.01 Sqrt[scale]]],
  45. Circle[centre - scale RotationMatrix[\[Theta]].{0, 1},
  46. scale/Sqrt[2],
  47. {\[Theta] + Pi/4, \[Theta] +
  48. Pi/4 + (2 Pi/4 ) Max[0, Min[1, 2 t]]}],
  49. Circle[
  50. centre -
  51. scale RotationMatrix[\[Theta]].{1/\[Phi], 1/(2 \[Phi]^3)},
  52. scale/(2 \[Phi]), {\[Theta] - Pi/4 - 0.1, \[Theta] - Pi/4 -
  53. 0.1 + Max[0, Min[1, 2 (t - 0.5)]] (Pi/2 + 0.2)}]
  54. }
  55. ]
  56. ];
  57. squares = Select[allps, Not[First[#]] &];
  58. graphics = Map[graphic, allps];
  59. Manipulate[
  60. Graphics[{
  61. EdgeForm[Black], FaceForm[],
  62. If[t < Length@squares - 1,
  63. {graphics[[;; 1 + 3 Floor[t + 1]]],
  64. {EdgeForm[Opacity[Mod[t, 1]]],
  65. graphics[[
  66. Max[1, 2 + 3 (Floor[t + 1])] ;; Max[1 + 3 Floor[t + 2], 1]]]}}
  67. , {}],
  68. Table[
  69. {
  70. ColorData["DarkRainbow"][(i/(Length@squares - 1))^0.5],
  71. arcs[squares[[i]]][t - i + 1]
  72. }
  73. , {i, Length@squares}]
  74. }, PlotRange -> {{-\[Phi], \[Phi]}, {-1, 1}}/1.9]
  75. ,{t,0,Length@squares - 1}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement