Re: Need Help With Locator in a Manipulate
- To: mathgroup at smc.vnet.net
- Subject: [mg132267] Re: Need Help With Locator in a Manipulate
- From: Gregory Lypny <gregory.lypny at videotron.ca>
- Date: Tue, 28 Jan 2014 06:14:03 -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>
Excellent. Thanks. A reset button is important. I find a lot of my students never bother to see what is available under the little disclosure square (initial settings, bookmarks, etc.) that is built into Manipulate. A reset button will be even more important if I allow for changing the convex function randomly (hit reset and new function is introduced). Thanks again, Bob, Gregory On Mon, Jan 27, 2014, at 12:25 PM, Bob Hanlon <hanlonr357 at gmail.com> wrote: > I added a reset button along with your jitter fix: > > Manipulate[ > Module[ > {f, b, xmin = 0, xmax = 100}, > b = pt1[[2]] - m*pt1[[1]]; > f[{x1_, y1_}, x_] = (x1/x)^(a/(1 - a)) y1; > pt2 = {pt2[[1]], m pt2[[1]] + b}; > Plot[{f[pt1, x], m x + b}, > {x, 0, 100}, > Epilog -> {White, > Locator[Dynamic[pt2, pt2 = {pt2[[1]], > m pt2[[1]] + pt1[[2]] - m*pt1[[1]]}]], > Tooltip[Disk[pt1, {1, 2}], > StringForm["pt1 = ``", pt1]], > Tooltip[Disk[pt2, {1, 2}], > StringForm["pt2 = ``", pt2]]}, > AxesOrigin -> {0, 0}, > PlotRange -> {{xmin, xmax}, {-200, 200}}]], > Row[{ > Column[{ > Control[ > {{a, .5, "Shape (a)"}, .2, .8, .01, > Appearance -> "Labeled"}], > Control[ > {{m, -1, "Slope (m)"}, -3, 3, .01, > Appearance -> "Labeled"}]}], > Spacer[20], > Button["Reset", a = .5; m = -1; > pt1 = {10, 80}; pt2 = {50, 40}]}], > {{pt1, {10, 80}}, Locator}, > {{pt2, {50, 40}}, Locator, Appearance -> None}] > > > Bob Hanlon > > > > On Sun, Jan 26, 2014 at 5:01 PM, Gregory Lypny <gregory.lypny at videotron.ca> wrote: > Thanks again Bob, > > Much appreciated as always. I figured out how to stop the jiggle. I put the statement for resetting the locator in the Epilog of the plot in the way I described in my previous email > > Locator[Dynamic[pt2, pt2 = {pt2[[1]], m pt2[[1]] + pt1[[2]] - m*pt1[[1]]}]] > > and in the control section of the Manipulate, I set the Appearance of the locator to None. > > {{pt2, {25, 80}}, Locator, Appearance -> None}, > > That way the locator is visible only in its reset position. Its pretty smooth now. I'm going to include your tooltips. Nice idea! > > Gregory > > > On Sun, Jan 26, 2014, at 4:55 PM, Bob Hanlon <hanlonr357 at gmail.com> wrote: > >> I don't know how to stop the giggle but this adds tooltips over the locators. I also changed the definition of the curve to be a more direct function of x. >> >> Manipulate[ >> Module[ >> {f, b, xmin = 0, xmax = 100}, >> b = pt1[[2]] - m*pt1[[1]]; >> f[{x1_, y1_}, x_] = (x1/x)^(a/(1 - a)) y1; >> pt2 = {pt2[[1]], m pt2[[1]] + b}; >> Plot[{f[pt1, x], m x + b}, >> {x, 0, 100}, >> Epilog -> {White, >> Tooltip[Disk[pt1, {1, 2}], StringForm["pt1 = ``", pt1]], >> Tooltip[Disk[pt2, {1, 2}], StringForm["pt2 = ``", pt2]]}, >> 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, 40}}, Locator}] >> >> >> Bob Hanlon > >
- References:
- Need Help With Locator in a Manipulate
- From: Gregory Lypny <gregory.lypny@videotron.ca>
- Need Help With Locator in a Manipulate