MathGroup Archive 2014

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

Search the Archive

Re: Need Help With Locator in a Manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132271] Re: Need Help With Locator in a Manipulate
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Tue, 28 Jan 2014 06:15:23 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20140126081421.81CD369D3@smc.vnet.net>

Reposition the locator point each time the locator is moved.


Manipulate[
 Module[{f, b, xmin = 0, xmax = 100, k},
  b = pt1[[2]] - m*pt1[[1]];
  k[{x_, y_}, a_] := x^a y^(1 - a);


  pt2 = {#[[1]], m #[[1]] + b} &[pt2];


  Plot[{(k[pt1, a]/x^a)^(1/(1 - a)), m x + b},
   {x, 0, 100},
   AxesOrigin -> {0, 0},
   PlotRange -> {{xmin, xmax}, {Automatic, 200}}]],
 {{a, .5, "Shape (a)"}, .2, .8, .01,
  Appearance -> "Labeled"},
 {{m, -1, "Slope (m)"}, -3, -.4, .01,
  Appearance -> "Labeled"},
 {{pt1, {10, 80}}, Locator},
 {{pt2, {50, 50}}, Locator}]



Bob Hanlon




On Sun, Jan 26, 2014 at 3:14 AM, Gregory Lypny
<gregory.lypny at videotron.ca>wrote:

>
> Hello everyone,
>
> I'm creating a Manipulate that has two locators. I was able to get the
> first locator, pt1, working the way I want, but am not sure how to handle
> the second, pt2.
>
> Locator pt1 determines the intersection of two curves, a straight line
> with slope m and a power function, k[], with shape parameter a. Both m and
> a can be varied using sliders. I want the second locator, pt2, to be
> constrained to move along the line determined by locator pt1 and slope m.
> In a previous post some time ago, Bob Hanlon and John Fultz kindly showed
> me how to constrain a locator to move around the perimeter of a circle, but
> this used DynamicModule, and I am not sure how to bring this into a
> Manipulate. Any guidance would be greatly appreciated.  The code for my
> Manipulate is below. Right now, locator pt2 is arbitrarily set to {50,50}
> but it doesn't do anything.
>
>
> Manipulate[
> Module[{f,b,xmin=0,xmax=100,k},
> b=pt1[[2]]-m*pt1[[1]];
> k[{x_,y_},a_]:=x^a y^(1-a);
> Plot[{(k[pt1,a]/x^a)^(1/(1-a)),m x +b},{x,0,100},
> AxesOrigin->{0,0},
> PlotRange->{Automatic,{0,200}}]],
> {{a,.5,"Shape (a)"},.2,.8,Appearance->"Labeled"},
> {{m,-1,"Slope (m)"},-3,-.4,Appearance->"Labeled"},
> {{pt1,{10,80}},Locator},
> {{pt2,{50,50}},Locator}]
>
> Regards,
>
> Gregory Lypny
>
>
>



  • Prev by Date: Re: How Can I Change the Appearance of a Locator in Manipulate
  • Next by Date: Re: Need Help With Locator in a Manipulate
  • Previous by thread: Re: Need Help With Locator in a Manipulate
  • Next by thread: Re: Need Help With Locator in a Manipulate