Message Boards Message Boards

0
|
5899 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Is it possible to get distance between two points on a graph?

Posted 10 years ago

Something similar like getting coordinates? Is that possible?

Or, what would be the simplest way? Note that I can only read data from a graph.

POSTED BY: Mitja Jan?i?
5 Replies

Here's another one. Click on the graphic to change the base point and then the distance to where the mouse is currently located is displayed below.

DynamicModule[{u = {0, 0}},
 Column[{
   LocatorPane[Dynamic[u], Plot[x^2, {x, -1, 4}]],
   Dynamic@EuclideanDistance[u, MousePosition["Graphics"]]}
  ]
 ]

General principle: the dynamic programing and interface in Mathematica is available to do pretty much whatever you want in terms of sophisticated (or modest as in this example) user interface programming.

Hope this helps! --David

POSTED BY: David Reiss

yes :D

My point is, I don't want to do that. :D I would like to set up a starting point and than measure the distance from that point to my cursor anywhere on a graph. (Like: DIRECTLY. So just as you can see coordinates shown directly on the right side of the cursor, I would like to have distance, if possible?)

EDIT: Ok I can see you edited your post. That last idea sounds pretty interesting. I will try that one. Thanks!

POSTED BY: Mitja Jan?i?

Just take the resulting points and past them into EuclideanDistance... but remove the outer brackets or use Apply as in

EuclideanDistance @@ {{1.384, 1.878}, {1.896, 2.33}}

one also could certainly create a tool to do this using things like this (it gives the distance between the last two points created--create new points by alt-clicking on windows or command-clicking on OSX):

Manipulate[
 Column[{
   Plot[x^2, {x, -1, 4}],
   If[Length[u] > 1, EuclideanDistance @@ Take[u, -2], 0]}
  ], Button["reset", u = {}],
 {{u, {}}, Locator, LocatorAutoCreate -> True}]
POSTED BY: David Reiss

Jup, that's a good answer how to get coordinates.

But my question is, if there is a similar tool to get distance between two arbitrary points (which i would select exactly as shown on the video you gave) in a plot?

POSTED BY: Mitja Jan?i?
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