Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Arc[a_] :=
- Module[{xs = Accumulate[Join[{0}, First /@ a]],
- ys = Accumulate[Join[{0}, Last /@ a]]},
- Table[
- {{xs[[i]], ys[[i]]}, {xs[[i]], ys[[i]]} + a[[i]]}
- , {i, Length[a]}
- ]
- ];
- ArcArray[a_] :=
- Module[{xs = Accumulate[Join[{0}, First /@ a]],
- ys = Accumulate[Join[{0}, Last /@ a]], out},
- out = Table[0, {j, Last[xs]}, {i, Last[ys]}];
- Do[
- out[[1 + xs[[i]] ;; xs[[i]] + a[[i, 1]],
- 1 + ys[[i]] ;; ys[[i]] + a[[i, 2]]]] = 1;
- , {i, Length[a]}
- ];
- out
- ];
- InterpolateArcs[a1_, a2_, order_, t_] := (
- Table[
- a1[[order[[i]]]] (1 - t) + a2[[i]] t
- , {i, Length[a1]}]
- );
- Tmax = 5;
- arc = {{1, 9}, {1, 7}, {1, 3}, {1, 4}, {1, 3}, {1, 2}, {1, 2}, {1,
- 2}, {1, 3}, {1, 1}, {1, 2}, {1, 1}, {1, 2}, {1, 1}, {1, 2}, {1,
- 1}, {1, 1}, {1, 1}, {1, 1}, {1, 2}, {1, 1}, {1, 1}, {1, 1}, {2,
- 1}, {1, 1}, {1, 1}, {1, 1}, {2, 1}, {1, 1}, {1, 1}, {2, 1}, {2,
- 1}, {1, 1}, {2, 1}, {2, 1}, {3, 1}, {2, 1}, {3, 1}, {3, 1}, {4,
- 1}, {5, 1}, {6, 1}};
- arc = {{1, 7}, {1, 2}, {1, 3}, {1, 4}, {1, 3}, {1, 2}, {1, 2}, {1,
- 2}, {1, 1}, {1, 1}, {1, 2}, {1, 1}, {2, 1}, {1, 1}, {3, 1}, {2,
- 1}, {3, 1}, {3, 1}, {2, 1}, {7, 1}};
- arcsorteds = Table[
- LocalSort[-#[[2]]/#[[1]] &, arc, i],
- {i, Tmax}];
- o = {LocalSort[-#[[2]]/#[[1]] &, arc, True]};
- Do[
- AppendTo[o,
- LocalSort[-#[[2]]/#[[1]] &, arcsorteds[[i]], True]
- ];
- , {i, Tmax - 1}];
- arcs = Join[{arc}, arcsorteds];
- step[\[Tau]_] := Sum[(0.5 + 0.5 Tanh[5 (\[Tau] - i)]), {i, Tmax}];
- Clear[frame];
- frame[\[Tau]_] := Module[{t = step[\[Tau]], recs},
- recs =
- InterpolateArcs[Arc[arcs[[Floor[t] + 1]]],
- Arc[arcs[[Floor[t] + 2]]], o[[Floor[t] + 1]], t - Floor[t]];
- Graphics[
- Table[Rotate[{
- White, EdgeForm[White],
- (Rectangle @@ #) & /@ recs,
- Black,
- Line /@ recs
- }, i Pi/2, {1, 1} 19],
- {i, 8}]
- , ImageSize -> 400, PlotRange -> All, Background -> Black]
- ];
- Manipulate[
- frame[\[Tau]]
- ,
- {\[Tau], 0, Tmax - 1}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement