MathGroup Archive 2007

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

Search the Archive

Re: Re: Re: Locator question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79508] Re: [mg79452] Re: [mg79433] Re: Locator question
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Sat, 28 Jul 2007 05:31:00 -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>
  • Reply-to: drmajorbob at bigfoot.com

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: style question
  • Next by Date: Re: Re: Help with Root function
  • Previous by thread: Re: Locator question
  • Next by thread: Re: Re: Re: Locator question