Re: Errant post?
- To: mathgroup at smc.vnet.net
- Subject: [mg82665] Re: Errant post?
- From: Brainiac at xemaps.com
- Date: Sun, 28 Oct 2007 03:55:25 -0500 (EST)
Daniel,
Here's a function I wrote that seems to solve the problem.
clickCoordinateList[g_Graphics]:=DynamicModule[{pts = {}},
Column[
{ClickPane[
Dynamic@Show[g,
Graphics[{Black, Point /@ pts}]], (pts = Append[pts, #]) &],
StyleForm[
"\nStart clicking on the graph above. The list below will grow, \
with one new x-y coordinate pair for each click. When you're done, \
highlight the list from just before the first brace to just past the \
last one. Next, use Edit/Copy on the front end menu bar to put the \
list on the clipboard. Then you can Edit/Paste the list into a new \
input cell for further manipulation. If you highlight much beyond \
the list, you'll just get a string with the name of the internal \
coordinate list variable (pts$$) when you paste into a new cell, \
rather than the coordinates themselves. \n\n You may find it useful \
to copy this function into the init.m file in the \
$UserBaseDirectory/Kernel subdirectory so it's available every time \
you start Mathematica.\n", FontFamily -> "Helvetica", FontSize -> 12,
FontWeight -> Bold, FontColor -> Red],
Dynamic[pts]}]]
Here's an example of how to use this function:
gMyGraph=Plot[Sin[x]/x,{x,-10,10},GridLines->Automatic,Frame->True]
clickCoordinateList[Show[gMyGraph,ImageSize->500]]
pastedPoints=**** paste list from above here ****;
deltas=Rest[pastedPoints]-Most[pastedPoints];
approximatePathLength=Plus@@(Sqrt[#.#]&/@deltas)
---Joe DeWitte