0
$\begingroup$

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

Manipulate[
 Graphics[
  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}]
$\endgroup$
1
$\begingroup$

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:

Manipulate[
 DynamicModule[{m, trail},
  m[x_] := RotationMatrix[6 x];
  trail = Table[m[xx].{0, Cos[\[Pi]*6*xx]}, {xx, 0, x, 0.01}];
  Graphics[{
    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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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