Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x[t_] := {t, TriangleWave[t]};
- dt = 0.01;
- {tmin, tmax} = {0, 2};
- ds = 1/50.0;
- pts = Table[x[t], {t, tmin, tmax, dt}];
- dists = Round[
- Accumulate[Map[Norm, (pts - RotateRight[pts])[[2 ;;]]]]/ds];
- posns = Table[Flatten[Position[dists, i]][[1]], {i, Union[dists]}];
- frame[n_] := Module[{imax},
- imax = Length[posns] - n;
- Graphics[{
- Table[
- {ColorData["DarkRainbow"][i/imax],
- Line[{pts[[posns[[i]]]], pts[[posns[[i + n]]]]}]}
- , {i, 1, imax}],
- {Thickness[0.005], RGBColor[0.0, 0.2, 0.4], Line[pts]}
- }, ImageSize -> 400, ImagePadding -> 10]];
- Manipulate[frame[n],{n,1,200}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement