MathGroup Archive 2007

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

Search the Archive

Re: Locator question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79292] Re: [mg79272] Locator question
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Tue, 24 Jul 2007 05:56:20 -0400 (EDT)
  • References: <2851721.1185180232088.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

How's this?

Manipulate[
  Show[
   Plot[g[x], {x, 0, 2 \[Pi]}],
   p[[2]] = g@p[[1]]; slope = D[g[x], x] /. x -> p[[1]];
   Plot[p[[2]] + slope (x - p[[1]]), {x, 0, 2 \[Pi]}],
   PlotLabel ->
    Style["slope of f(x)= " <>
      ToString[NumberForm[slope, {6, 4}]]]], {{g, Sin,
    "function"}, {Sin -> TraditionalForm[Sin[x]],
    Cos -> TraditionalForm[Cos[x]], #^2 & -> TraditionalForm[x^2]},
   ControlType -> PopupMenu}, {{p, {0, 0}}, Locator}]

Bobby

On Mon, 23 Jul 2007 02:40:52 -0500, Mike <mjp.1 at comcast.net> wrote:

> All,
>
> I'm trying to get the locator to track a point along a given curve:
>
>
> bothfandtan[g_, p_] :=
>  Module[{f = g,
>    eqline = (D[g, x] /. x -> p[[1]]) (x - p[[1]]) + p[[2]]},
>   Show[{Plot[f, {x, 0, 2 \[Pi]}], Plot[eqline, {x, 0, 2 \[Pi]}]}]]
>
> Manipulate[
>  Show[bothfandtan[g, p],
>   PlotLabel ->
>    Style["slope of f(x)= " <>
>      ToString[NumberForm[D[g, x] /. x -> p[[1]], {6, 4}]]]],
>  {{g, Sin[x], "function"},
>   {Sin[x] -> TraditionalForm[Sin[x]],
>    Cos[x] -> TraditionalForm[Cos[x]],
>    x^2 -> TraditionalForm[x^2]}}, {{p, {0, 0}}, Locator},
>  SaveDefinitions -> True]
>
>
> I've tried a number of possibilities, but I can't seem to get this to 
> work. Mathematica's help section on this isn't very helpful.
>
> Thanks for the help...
>
> Mike
>
>



-- 

DrMajorBob at bigfoot.com


  • Prev by Date: Re: Arbitrarily formatted text in plot labels
  • Next by Date: Re: Mathematica to .NET compiler
  • Previous by thread: Re: Locator question
  • Next by thread: Re: Re: Locator question