# Track a moving peak on a periodic ListAnimate plot

I have a ListAnimate plot and I want to track the position of the peak as it moves.

Is there any way to do this which takes into account the fact that the peak of the wave moves past the window of the plot on the right hand side.

ListAnimate[Table[ListLinePlot[Table[Sin[2*Pi*i/100 - j], {i, 0, 100}]], {j,0,10}]]


Any help is greatly appreciated!

Edit:

The value for distance traveled should keep counting and not reset each time it passes the point it began.

Is there any way to do this which takes into account the fact that the peak of the wave moves past the window of the plot on the right hand side.

ListAnimate[Table[With[{t = Table[{i, Sin[2*Pi*i/100 - j]}, {i, 0, 100}]},
ListLinePlot[t, Epilog -> {Orange, PointSize[Large], Point@MaximalBy[Last][N@t]}]],
{j, 0, 10}]] Update:

firstpeak = First@MaximalBy[Last][N@Table[{i, Sin[2*Pi*i/100]}, {i, 0, 100}]];

ListAnimate[Table[With[{t = Table[{i, Sin[2*Pi*i/100 - j]}, {i, 0, 100}]},
ListLinePlot[t,
Epilog -> {Orange, PointSize[Large],
Point[currentpeak = MaximalBy[Last][N@t]]},
PlotLabel -> Column[{"distance traveled by orange point",
ArcLength[Line[{firstpeak, First@currentpeak}]]},
Alignment -> Center]]],
{j, 0, 10}]] • Is there anyway to find the total distance that the orange point "travels" during the animation and extract this separately? – James Feb 16 at 23:44
• @James, please see the update. – kglr Feb 17 at 0:03
• What I mean is the cumulative distance the peak travels. The value for distance traveled should keep counting and not reset each time it passes the point it began. Also, is there a way to view these values as a list and not as past of the plot label? – James Feb 17 at 0:10
• @James, I suggest you update your question with the additional requirements you have posted in comments (or, better yet, post them as new questions). – kglr Feb 17 at 0:16

Would something like this do what you want:

ClearAll[values, maxValues, valuesAndMax];
values = Table[{i, Sin[2*Pi*i/100 - j]}, {j, 0, 10}, {i, 0, 100}];
maxValues =
Flatten[#,
1] & /@ (With[{max = Max[#[[;; , -1]]]},
Select[#, #[] == max &]] & /@ values);
valuesAndMax = Transpose[{maxValues, values}];
ListAnimate[
ListLinePlot[#[],
Epilog -> {Orange, PointSize -> .02, Point[#[]]}] & /@
valuesAndMax] The max value is shown as an orange point that moves with the graphs.

• Is there anyway to find the total distance that the orange point "travels" during the animation and extract this separately? – James Feb 16 at 22:24