Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

LocatorAutoCreate in 2-parameter Manipulate?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109188] LocatorAutoCreate in 2-parameter Manipulate?
  • From: Murray Eisenberg <murrayeisenberg at gmail.com>
  • Date: Fri, 16 Apr 2010 05:51:29 -0400 (EDT)

The following code works to plot, for a simple harmonic oscillator, the 
phase plane trajectory through the point where you move the Locator:

   soln[t_, x0_, v0_] := {x0 Cos[t] + v0 Sin[t], v0 Cos[t] - x0 Sin[t]}

   Manipulate[{x0, v0} = u;
      ParametricPlot[soln[t, x0, v0], {t, 0, 4 \[Pi]},
          PlotRange -> {{-4, 4}, {-4, 4}}, PlotStyle -> Thick],
      {u, {-3.5, -3.5}, {3.5, 3.5}},
         ControlType -> Locator]

I now want to be able to create (and destroy) locators there.  So I 
tried option LocatorAutoCreate:

   Manipulate[{x0, v0} = u;
      ParametricPlot[soln[t, x0, v0], {t, 0, 4 \[Pi]},
         PlotRange -> {{-4, 4}, {-4, 4}}, PlotStyle -> Thick],
      {{u, {-3.5, -3.5}, {3.5, 3.5}},
       Locator, LocatorAutoCreate -> True}]

But this does not work: I still get only one locator and corresponding 
one curve shown after Alt-Click somewhere.

[Note that changing the manipulate parameter specification to the form 
shown on page ref/LocatorAutoCreate...

   {{u, {{-3.5, -3.5}, {3.5, 3.5}}}, Locator, LocatorAutoCreate -> True}

... gives completely spurious results.]

Is it possible to fix this and yet still do it within a Manipulate. For 
good reasons I do NOT want to totally "roll my own" using DynamicModule, 
etc.

-- 
Murray Eisenberg                     murrayeisenberg at gmail.com
80 Fearing Street                    phone 413 549-1020 (H)
Amherst, MA 01002-1912


  • Prev by Date: Re: Through[(a+b+b)[x]]
  • Next by Date: Re: piecewise function
  • Previous by thread: Re: How to simplify "Integrate[2 f[x], {x, 0, 1}]/2" to "Integrate[f[x],
  • Next by thread: Re: DynamicModule not saving reliably a variable between