I have a code in which I use the Manipulate feature to cause a point to oscillate along a line which is being rotated. What I've been trying to figure out is how to make the point leave a trail though all of the points that it travels through. I've tried to use a LineListPlot using 0,0 as the starting point and 0,Cos[Pi*6*x] as the end thinking that it would continually update the second point, but that didn't work. Here's the code

  Rotate[{{Red, Rectangle[{-(1/128), -2}, {1/128, 2}]}, {Blue, PointSize[0.02], Point[{0, Cos[\[Pi]*6*x]}]}},
   360 Degree*(6*x)],
  PlotRange -> {{-2.5, 2.5}, {-2, 2}},
  Axes -> True],
 {x, 0, 1}]

1 Answer 1


An easy way is to create a table of points that you have visited. Mathematica should be fast enough to do this on each update. In this setting, I recommend that you rather use a RotationMatrix m because it can be applied to each point instead of rotating the whole graphics:

 DynamicModule[{m, trail},
  m[x_] := RotationMatrix[6 x];
  trail = Table[m[xx].{0, Cos[\[Pi]*6*xx]}, {xx, 0, x, 0.01}];
    PointSize[0.01], Green, Line[trail], Point[trail],
    Red, Line[{m[x].{0, -2}, m[x].{0, 2}}], Blue, PointSize[0.02], 
    Point[m[x].{0, Cos[\[Pi]*6*x]}]
    }, PlotRange -> {{-2.5, 2.5}, {-2, 2}}, Axes -> True]
  ], {x, 0, Pi}]

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.