MathGroup Archive 2010

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

Search the Archive

Re: Customizing Manipulate's Autorun

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110638] Re: Customizing Manipulate's Autorun
  • From: "Ingolf Dahl" <ingolf.dahl at telia.com>
  • Date: Wed, 30 Jun 2010 01:49:00 -0400 (EDT)

Thanks for the comments!
Yes, I have considered setting bookmarks and use bookmark animation.
However, the demonstration I presently am trying to develop is a bit more
complicated that the example I gave in the letter. It works in all other
ways than bookmark animation, but when I ask for "Animate bookmarks"
Mathematica runs havoc, and I get a pink mess of errors. One of the first
errors is 

ListPlot::lpn:
Interpolation[{{{-2.,-2.},{2.4,-2.},{2.,2.},{-4.08998,1.42527},{-1.02122,4.2
2125},{-0.339269,0.64103}},<<3>>,{{-2.,-2.},{2.4,-2.},{2.,2.},{-4.08998,1.42
527},{-1.02122,4.22125},{-0.339269,0.64103}}},InterpolationOrder->0][4.39874
7253417969`] is not a list of numbers or pairs of numbers.

I also get

Interpolation::indim: "\!\(\*
StyleBox[\"\\\"The coordinates do not lie on a structured tensor product
grid.\\\"\", \"MT\"]\) "

I think this is a bug. I believe that the intension is to have implicit
coordinate positions for the interpolation, with a list only of function
values, Interpolation[{f1, f2, f3,...}]. In this case, the function values
are point lists. (The point lists are of variable length, but that does not
matter here and now.) But Mathematica thinks that we try to construct an
interpolation of multidimensional data, and protests, because the points do
not lie on a structured tensor product grid.

When bookmark animation did not work for me, I concentrated on understanding
Autorun, since even if bookmark animation had worked, I am not sure that I
would be satisfied with it. As I see it, the bookmark animation is like
ready-made clothing: when it fits, it fits, and when it works, it works, but
sometimes a real tailor is needed.

The second suggestion about "ControlType -> None" I have inserted into the
notebook. Not as fun as my "If[False,..." construction, but a more proper
programming solution.

I will update the notebook at 
http://www.familydahl.se/mathematica/CustomizingManipulatesAutorun.nb
further, if I get more good suggestions.

Best regards

Ingolf Dahl

> -----Original Message-----
> From: John Fultz [mailto:jfultz at wolfram.com]
> Sent: den 29 juni 2010 14:28
> To: mathgroup at smc.vnet.net
> Subject: [mg110632] Re: Customizing Manipulate's Autorun
> 
> Two comments...
> 
> First, did you consider setting bookmarks and animating through them
> instead of
> using the autorun functionality?  This is well-documented and generally
> easier
> to puzzle out than the approach you took, I think.  The bookmarks serve
> as
> keyframes which you can animate between.  Something like this...
> 
> Manipulate[
>  Graphics[{color, Disk[{x, y}, 0.1]},
>   PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}}], {{color,
>    Black}, {Black -> "Black", Red -> "Red"}}, {{x, 0}, -1,
>   1}, {{y, 0}, -1, 1},
>  Bookmarks -> {"frame1" :> (x = 1; y = 0; color = Black),
>    "frame2" :> (x = 0; y = -1; color = Red),
>    "frame3" :> (x = -1; y = 0; color = Red),
>    "frame4" :> (x = 0; y = 1; color = Black),
>    "frame5" :> (x = 1; y = 0; color = Black)}]
> 
> Then choose "Animate Bookmarks" instead of "Autorun".
> 
> Second, there is a much easier technique for making a hidden control.
> Manipulate supports this directly using the ControlType option.  E.g.,
> 
> Control[{{t, 0}, 0, 4*Pi, Pi/12, ControlType -> None}]
> 
> There are several examples in the Manipulate documentation which
> highlight this
> usage.
> 
> Sincerely,
> 
> John Fultz
> jfultz at wolfram.com
> User Interface Group
> Wolfram Research, Inc.
> 
> 
> On Tue, 29 Jun 2010 06:58:55 -0400 (EDT), Ingolf Dahl wrote:
> > I was about to write to MathGroup with a question how to customize
> the
> > Autorun feature of Manipulate to stop it from running the controls
> > sequentially and instead shake them simultaneously. But when I was
> > preparing the question I found a solution, and since it was
> nontrivial I
> > want to share it. The trick was to create a special hidden control,
> which
> > manipulates the default values of the other controls dynamically.
> >
> > It is in the essence of this kind of solutions that it describes
> > undocumented, or poorly documented features of Mathematica, and such
> > features might be changed in future versions. But if the content of
> this
> > notebook already was described in the documentation, there was no
> reason
> > for me to repeat it.
> >
> > Sometimes we might want to control the Autorun feature of a
> Manipulate
> > cell. Autorun can be started from the little "+" in a gray circle in
> the
> > upper right corner of the Manipulate cell. Let us start with a simple
> > Manipulate cell.
> >
> > Manipulate[
> > Graphics[{color, Disk[{x, y}, 0.1]},
> > PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}}], {{color,
> > Black}, {Black -> "Black", Red -> "Red"}}, {{x, 0}, -1,
> > 1}, {{y, 0}, -1, 1}]
> >
> > Say, that we want the dot going around a circle instead! We add
> another
> > control t to fix that, and let that control take over Autorun :
> >
> > Manipulate[
> > If[t > 0, x = Cos[t]; y = Sin[t]; color = Red, color = Black];
> > Graphics[{color, Disk[{x, y}, 0.1]},
> > PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}}], {{color,
> > Black}, {Black -> "Black", Red -> "Red"}}, {{x, 0}, -1,
> > 1}, {{y, 0}, -1, 1}, {t, 0, 4*Pi}, AutorunSequencing -> {{4, 10}}]
> >
> > If we test the Autorun, we see a jitter in the other controls, since
> they
> > are reset to their default whenever they are changed by t. The
> processor
> > will be occupied by changing the controls back and forth. Moreover,
> the
> > color control is locked up when Autorun is inactive. Can we fix that?
> > Yes, we might control the other parameters without jitter if we
> control
> > their default values dynamically. We might check if we are in the
> Autorun
> > mode by testing the variable  Typeset`bookmarkMode$$. The variable t
> has
> > also been changed to run stepwise.
> >
> > Manipulate[
> > If[Typeset`bookmarkMode$$ === "Autorun",
> > If[t < 2*Pi, color1 = Red, color1 = Black]; x1 = Cos[t];
> > y1 = Sin[t]];
> > Graphics[{color, Disk[{x, y}, 0.1]},
> > PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}}],
> > Control[{{x, Dynamic[x1], "x"}, -1, 1}],
> > Control[{{y, Dynamic[y1], "y"}, -1, 1}],
> > Control[{{color, Dynamic[color1], "color"}, {Black -> "Black",
> > Red -> "Red"}}], Control[{{t, 0}, 0, 4*Pi, Pi/12}],
> > AutorunSequencing -> {{4, 10}},
> > Initialization :> {color1 = Black; x1 = 0.; y1 = 0.}]
> >
> > Can we have the control for t invisible? Note the uncommon
> programming
> > construction "If[False,...". In this embedding the control for t will
> > never show up, but it is anyway found by the AutorunSequencing as the
> > fourth control.
> >
> > Manipulate[
> > If[Typeset`bookmarkMode$$ === "Autorun",
> > If[t < 2*Pi, color1 = Red, color1 = Black]; x1 = Cos[t];
> > y1 = Sin[t]];
> > Graphics[{color, Disk[{x, y}, 0.1]},
> > PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}}],
> > Control[{{x, Dynamic[x1], "x"}, -1, 1}],
> > Control[{{y, Dynamic[y1], "y"}, -1, 1}],
> > Control[{{color, Dynamic[color1], "color"}, {Black -> "Black",
> > Red -> "Red"}}],
> > Dynamic[If[False, Control[{{t, 0}, 0, 4*Pi, Pi/12}],
> > Pane[" ", {0, 0}]]], AutorunSequencing -> {{4, 10}},
> > Initialization :> {color1 = Black; x1 = 0.; y1 = 0.}]
> >
> > Please send comments to ingolf.dahl at telia.com.
> > The corresponding notebook might be available at
> > http://www.familydahl.se/mathematica/CustomizingManipulatesAutorun.nb
> >
> > Best regards
> >
> > Ingolf Dahl
> 




  • Prev by Date: Re: numerical integration
  • Next by Date: Re: numerical integration
  • Previous by thread: Re: Customizing Manipulate's Autorun
  • Next by thread: Exporting a List of Tables with different Lengths to a tabulator