Want more features on Pastebin? Sign Up, it's FREE!

polygons to ellipses

By: Matthen on Nov 18th, 2012  |  syntax: None  |  size: 1.38 KB  |  views: 1,709  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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}]
clone this paste RAW Paste Data