Message Boards Message Boards

0
|
4475 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

A locator which follows a function?

Posted 9 years ago

Hello everyone.

I have the next problem: could be possible to create a locator which follows the path of a function, moving the mouse over the function? For example, a locator which follows the path of a sine.

Thank you.

POSTED BY: Daniel G
3 Replies
Posted 9 years ago

It´s exactly what I was looking for! Excuse me for my English.

Thank you very much Jesse.

POSTED BY: Daniel G

No problem! Glad to help.

POSTED BY: Jesse Friedman

I'm afraid I don't entirely understand what you're looking for. Does this suit your needs?

range = {0, 2 Pi};
sine = Plot[Sin[x], {x, range[[1]], range[[2]]}];
With[{x = Dynamic[MousePosition["Graphics", {0, 0}][[1]]]}, 
 Show[sine, 
  Graphics[Locator[{x, Sin[x]}, Enabled -> False], PlotRange -> {range, {-1, 1}}]]]

A locator following the x-position of the mouse and the y-position of a sine curve.

POSTED BY: Jesse Friedman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract