Re: Re: Locator question
- To: mathgroup at smc.vnet.net
- Subject: [mg79327] Re: [mg79292] Re: [mg79272] Locator question
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Wed, 25 Jul 2007 01:57:59 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <2851721.1185180232088.JavaMail.root@m35> <200707240956.FAA25082@smc.vnet.net>
- Reply-to: murray at math.umass.edu
The Locator is NOT tracking along the curve. That is, it is not constrained to be on the curve. The locator can be at any ({x,y} in the figure, although the point of tangency is, of course, constrained to lie on the curve plotted. DrMajorBob wrote: > 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 >> >> > > > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
- References:
- Re: Locator question
- From: DrMajorBob <drmajorbob@bigfoot.com>
- Re: Locator question