Advertisement
Matthen

polygons to ellipses

Nov 18th, 2012
2,449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. n = 12;
  2. ngen = 100;
  3. gen0 = RandomReal[{-1, 1}, {n, 2}];
  4. nextgen[gen_] := (gen + RotateLeft[gen])/2;
  5. gens = NestList[nextgen, gen0, ngen];
  6. frame[m_] := Graphics[{
  7. If[m - Floor@m == 0,
  8. {
  9. FaceForm[None],
  10. EdgeForm[Directive[Thick, Black]],
  11. Polygon[gens[[Floor@m]]],
  12. PointSize[0.025], Black,
  13. Point[gens[[Floor@m]]]
  14. },
  15. If[m - Floor@m == 0.25,
  16. {
  17. FaceForm[None],
  18. EdgeForm[Directive[Thick, Black]],
  19. Polygon[gens[[Floor@m]]],
  20. PointSize[0.025], Black,
  21. Point[gens[[Floor@m]]],
  22. Red,
  23. Point[gens[[Floor@m + 1]]]
  24. }
  25. ,
  26. If[m - Floor@m == 0.5,
  27. {
  28. FaceForm[None],
  29. EdgeForm[Directive[Thick, Black]],
  30. Polygon[gens[[Floor@m]]],
  31. PointSize[0.025], Black,
  32. Point[gens[[Floor@m]]],
  33. Red,
  34. Point[gens[[Floor@m + 1]]],
  35. EdgeForm[Directive[Thickness[0.0025], Red]],
  36. Polygon[gens[[Floor@m + 1]]]
  37. }
  38. ,
  39. If[m - Floor@m == 0.75,
  40. {
  41. FaceForm[None],
  42. EdgeForm[Directive[Thick, Red]],
  43. Polygon[gens[[Floor@m + 1]]],
  44. PointSize[0.025], Red,
  45. Point[gens[[Floor@m + 1]]]
  46. }
  47. ,
  48. {}
  49. ]
  50. ]
  51. ]
  52. ]
  53.  
  54. }
  55. , PlotRange -> 1, ImageSize -> 300];
  56. Manipulate[
  57. frame[m]
  58. , {m, 1, ngen - 1, 0.25}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement