4
$\begingroup$

Basically, I want to move a graphic (such as a circle) along a given path (such as sin(x)). I was thinking that the trick might be making the x and y coordinates of the circle vary based on the equation, but I have not been able to make anything except a circle that just sits there.

$\endgroup$
  • $\begingroup$ Have a good look at the help for Manipulate and Circle and Graphics. Also, the demonstrations site is bound to yield some relevant code... $\endgroup$ – Yves Klett Jan 3 '13 at 12:31
  • $\begingroup$ In addition, it is always a good idea to post the code you´ve tried already so we get an idea how to best help you out. $\endgroup$ – Yves Klett Jan 3 '13 at 12:38
  • 1
    $\begingroup$ Thank you! I'll make sure to post my erroneous code in the future. And I'll definitely be spending time on that demonstrations site, it's awesome. $\endgroup$ – kneu93 Jan 3 '13 at 12:41
  • $\begingroup$ You could (and should) still add your code to the question - this will help future visitors to make more quickly sense of this thread and see how PlotRange can help them in similar situations. $\endgroup$ – Yves Klett Jan 3 '13 at 13:39
  • $\begingroup$ The techniques discussed in this previous question would seem to be relevant to this question. $\endgroup$ – m_goldberg Jan 3 '13 at 14:25
4
$\begingroup$

You need to specify the PlotRange:

f[x_] := Sin[x];

Manipulate[Graphics[{Circle[{x, f[x]}, 0.5]}, PlotRange -> {{0, 5}, {-2, 2}}], {x, 0, 5}]
$\endgroup$
  • $\begingroup$ Thank you, the missing PlotRange was exactly my issue. Thanks so much for the speedy response! $\endgroup$ – kneu93 Jan 3 '13 at 12:44
  • $\begingroup$ I'm new too, and that was exactly the problem I had! $\endgroup$ – nickjamesuk Jan 3 '13 at 12:45

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.