MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Re: Locator question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79526] Re: [mg79452] Re: [mg79433] Re: Locator question
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Sat, 28 Jul 2007 05:40:19 -0400 (EDT)
  • References: <f86r55$pc7$1@smc.vnet.net> <200707250930.FAA26363@smc.vnet.net> <f89pve$5jn$1@smc.vnet.net> <200707261030.GAA09683@smc.vnet.net> <12053562.1185538119591.JavaMail.root@m35> <op.tv4rezijqu6oor@monster.gateway.2wire.net> <8266975.1185567612261.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

I didn't know Locators existed at ALL, before version 6.

Yet this code works in v 5.0.1 and NOT in v 6???

(I have continually updated WinXP and Mathematica 6.0.1.)

Bobby

On Fri, 27 Jul 2007 15:15:41 -0500, Murray Eisenberg  
<murray at math.umass.edu> wrote:

> Under Windows XP with Mathematica 5.0.1, and with the version of  
> trackPointOnPlot nearest the top of my posting, I see only one locator!
>
> DrMajorBob wrote:
>> That code gives me two locators, neither of them on the curve. One  
>> can't be "grabbed", but it moves when I move the other one. If I move 
>> the second locator to the curve, the other also moves to the curve, at  
>> another point (but sometimes beyond the left limit of the plot).
>>  Bizarro!
>>  Am I the only one seeing this?
>>  Bobby
>>  On Fri, 27 Jul 2007 04:48:07 -0500, Murray Eisenberg  
>> <murray at math.umass.edu> wrote:
>>
>>> Very nice!  An observation and a question:
>>>
>>> 1. Probably it would be more reasonable that the third, optional,
>>> argument be not an {x,y} point, but instead the x-coordinate of that
>>> point, since the point is supposed to be on the graph anyway. The
>>> modification for that is trivial:
>>>
>>>   trackPointOnPlot[f_, {a_, b_}, strt_: Automatic] :=
>>>      Module[{start = strt /. Automatic -> a},
>>>         DynamicModule[{p = {start, f[start]}},
>>>            Column[{LocatorPane[Dynamic[p, (p = {First@#, f[First@#]})  
>>> &],
>>>                    Plot[f[x], {x, a, b}]], Dynamic[p]}]]]
>>>
>>> 2. Where/how did you discover the "trick" of using Automatic as a
>>> default value for an argument?  I don't recall seeing that before.
>>>
>>> Albert wrote:
>>>> ...The following is my attempt to solve your issue, it only uses one
>>>> definition, but introduces some extra code...
>>>>
>>>> trackPointOnPlot[f_, {a_, b_}, strt_: Automatic] :=
>>>>   Module[{start = strt /. Automatic -> {a, f[a]}},
>>>>     DynamicModule[{p = start},
>>>>      Column[{LocatorPane[Dynamic[p, (p = {First@#, f[First@#]}) &],
>>>>         Plot[f[x], {x, a, b}]], Dynamic[p]}]]
>>>>    ]
>>>
>>> Of course, per your suggestion, a simpler way but now using only the
>>> x-coordinate as third, optional, argument is:
>>>
>>>     trackPointOnPlot[f_, {a_, b_}, start_] :=
>>>        DynamicModule[{p = {start, f[start]}},
>>>           Column[{LocatorPane[Dynamic[p, (p = {First@#, f[First@#]})  
>>> &],
>>>                   Plot[f[x], {x, a, b}]], Dynamic[p]}]]
>>>
>>>     trackPointOnPlot[f_, {a_, b_}] := trackPointOnPlot[f, {a, b}, a]
>>>
>>
>



-- 

DrMajorBob at bigfoot.com


  • Prev by Date: Re: Searching list for closest match to p
  • Next by Date: Storing matrices
  • Previous by thread: Re: Re: Re: Locator question
  • Next by thread: Re: Re: Re: Re: Locator question