MathGroup Archive 2012

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

Search the Archive

Re: Constraining a Location to Move Along a Plot in a Manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127779] Re: Constraining a Location to Move Along a Plot in a Manipulate
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Wed, 22 Aug 2012 02:25:19 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20120821013043.F31B7684F@smc.vnet.net>

Manipulate[
 Module[{f, m, b, xmin = -5, xmax = 5},
  f[x_] :=
   (m*x + b /. Solve[{
        pt1[[2]] == m*pt1[[1]] + b,
        pt2[[2]] == m*pt2[[1]] + b},
       {m, b}][[1]]);
  Graphics[{
    Line[{{xmin, f[xmin]},
      {xmax, f[xmax]}}],
    AbsolutePointSize[8],
    Red,
    Tooltip[Point[{x, f[x]}], {x, f[x]}],
    Blue,
    Tooltip[Point[
      {InverseFunction[f][y], y}],
     {InverseFunction[f][y], y}]},
   Frame -> True, Axes -> False,
   PlotRange -> {{xmin, xmax}, {-5, 5}}]],
 {{x, -1, Style["x", Red, Bold, 12]}, -5, 5, 0.1,
  Appearance -> "Labeled"},
 {{y, 1, Style["y", Blue, Bold, 12]}, -5, 5, 0.1,
  Appearance -> "Labeled"},
 {{pt1, {-4, -4}}, Locator},
 {{pt2, {4, 4}}, Locator}]


Bob Hanlon


On Mon, Aug 20, 2012 at 9:30 PM, Gregory Lypny
<gregory.lypny at videotron.ca> wrote:
> Hello everyone,
>
> Awhile back, participants on this forum kindly showed me how to constrain a locator to move along a curve by using DynamicModule[...], an example of which is in the Help Centre.  But I can't figure out how to pull this off in a Manipulate,where I'm guessing that the locator would be a control.  Say I have a simple Manipulate that plots a line, y = mx + b, where m is control for changing the slope.  I would also like to have a locator that users can slide up and down the line in lieu of a slider control that draws a point on the line.
>
> Regards,
>
> Gregory
>



  • Prev by Date: trouble with NDSolve: how to diagnose a problem with initial conditions?
  • Next by Date: Washington DC Area Mathematica SIG
  • Previous by thread: Constraining a Location to Move Along a Plot in a Manipulate
  • Next by thread: Re: Constraining a Location to Move Along a Plot in a