Advertisement
Guest User

Polygon averaging

a guest
Dec 3rd, 2012
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. f[pts_, S_] := (
  2. M = Length[pts];
  3. new = ConstantArray[0, M];
  4. vec = pts;
  5. A = SparseArray[{{M, 1} -> 1, {i_, i_} -> 1, {i_, j_} /; j - i == 1 -> 1}, {M, M}];
  6. For[s = 1, s <= S, s++,
  7. new = A.vec/2;
  8. vec = new;];
  9. vec = Standardize[vec];
  10. vec = Append[vec, vec[[1]]];
  11. ListPlot[{vec, vec}, Joined -> {True, False}, AspectRatio -> 1, Axes -> False])
  12.  
  13. M = 75;
  14. max = 3 M Sqrt[M];
  15. step = Ceiling[max/200];
  16. pts = RandomReal[1, {M, 2}];
  17. ListAnimate[Table[f[pts, S], {S, 1, max, step}]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement