Advertisement
Matthen

Animate all divisions

Jun 1st, 2015
1,894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. OrderedDivisors[1] = {1};
  2. OrderedDivisors[n_] := Flatten[Table[
  3. Map[Flatten@Join[{m}, #] &, OrderedDivisors[n/m]]
  4. , {m, Divisors[n][[2 ;;]]}], 1];
  5. \[Gamma] = 0.5;
  6. FactorPs[{}, p_, s_, \[Theta]_] := p;
  7. FactorPs[divisors_, p_, s_, \[Theta]_] := Partition[Flatten[
  8. With[{n = divisors[[1]]},
  9. Table[
  10. FactorPs[
  11. divisors[[2 ;;]],
  12. p +
  13. s {Sin[ 2.0 Pi i / n + \[Theta]], Cos[2.0 Pi i /n + \[Theta]]},
  14. s \[Gamma] / Sqrt[n],
  15. \[Theta] + 2.0 Pi i /n
  16. ]
  17. , {i, n}]]], 2];
  18. FactorPs[divisors_] := FactorPs[divisors, {0, 0}, 1];
  19. FormatDivisors[divisors_] :=
  20. StringJoin[Riffle[ToString /@ divisors, " \[Cross] "]];
  21. m = 12;
  22. os = Reverse@OrderedDivisors[m];
  23. ps = Map[FactorPs, ods];
  24. colours = Table[ColorData["DarkRainbow"][i/m], {i, m}];
  25. Manipulate[
  26. Graphics[
  27. With[{\[Tau] = Mod[t, 1, 0]},
  28. {
  29. {
  30. PointSize[Medium],
  31. With[{pst = (1 - \[Tau]) ps[[Floor[t]]] + \[Tau] ps[[
  32. Min[Length@ps, Floor[t] + 1]]]},
  33. Table[
  34. {colours[[i]], Point[pst[[i]]]}, {i, m}]
  35. ]
  36. },
  37. {GrayLevel[0.1], Opacity[1 - \[Tau]^0.5],
  38. Text[Style[FormatDivisors[ods[[Floor[t]]]], FontSize -> 20,
  39. FontFamily -> "Arial"], {0, 0}], Opacity[\[Tau]^4],
  40. Text[Style[FormatDivisors[ods[[Min[Length@ps, Floor[t] + 1]]]],
  41. FontSize -> 20, FontFamily -> "Arial"], {0, 0}]}
  42. }
  43. ]
  44. , PlotRange -> 2],
  45. {t, 1, Length@ps}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement