RE: Real Time Animation

*To*: mathgroup at smc.vnet.net*Subject*: [mg36837] RE: [mg36796] Real Time Animation*From*: "DrBob" <drbob at bigfoot.com>*Date*: Sat, 28 Sep 2002 04:34:40 -0400 (EDT)*Reply-to*: <drbob at bigfoot.com>*Sender*: owner-wri-mathgroup at wolfram.com

You're right; I misunderstood your problem. First of all, never use Do -- forget it exists -- and don't put the SelectionMove, etc. commands inside a loop. That's your biggest problem. This should help: Table[Plot[ Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}}], {t, 0, 2Pi - Pi/32, Pi/32}]; SelectionMove[EvaluationNotebook[], All, GeneratedCell] FrontEndTokenExecute["OpenCloseGroup"] FrontEndTokenExecute["SelectionAnimate"] The first time through the animation is a bit slow because the frames are being generated, but then the cell group collapses and things are better. I used an increment that's an exact divisor of the period in order to catch the max and min values of Sin[t], as well as the zero value, on each swing. Use the period MINUS the step-size as the upper limit in order to avoid having a last frame identical to the first. I'm a bit annoyed at the tendency for the plot to "jump" near zero and Pi, but that's because the derivative of Sin is higher there, and we're not compensating by picking more points there. If we do pick more points there, however, we won't perceive t as time. If that's not a consideration, you could do it this way: f = Which[ -1 ? # ? 1, #, 1 < # ? 3, 2 - #, True, f@Mod[#, 4, -1] ] &; Table[Plot[ f[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}}], { t, -1, 2.9, 0.1}]; SelectionMove[EvaluationNotebook[], All, GeneratedCell] FrontEndTokenExecute["OpenCloseGroup"] FrontEndTokenExecute["SelectionAnimate"] Bobby -----Original Message----- From: Goyder Dr HGD [mailto:H.Goyder at rmcs.cranfield.ac.uk] To: mathgroup at smc.vnet.net Subject: [mg36837] RE: [mg36796] Real Time Animation Dear Bobby, Thank you for your reply but I don't see how this helps. You still get one show from the generation of the frames which you don't want the audience to see. The grouping and closing tidies up the frames but now it is too late. Hugh -----Original Message----- From: DrBob [mailto:drbob at bigfoot.com] To: mathgroup at smc.vnet.net Subject: [mg36837] RE: [mg36796] Real Time Animation Put this after the Plot statement, in the same cell: SelectionMove[EvaluationNotebook[], All, GeneratedCell] FrontEndTokenExecute["OpenCloseGroup"] FrontEndTokenExecute["SelectionAnimate"] Bobby Treat -----Original Message----- From: Goyder Dr HGD [mailto:H.Goyder at rmcs.cranfield.ac.uk] To: mathgroup at smc.vnet.net Subject: [mg36837] [mg36796] Real Time Animation In a presentation I wish to use Plot to generate a sequence of frames and then animate them. The problem is that the audience sees the animation twice. Once when the frames are being generated and then again after I have closed the group and double clicked on the top graphic. However, the first showing during generation is enough (but uncontrolled). Is it possible to tidy up the generation of the graphic so that it becomes the animation? I have tried the following Do[Plot[Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}}, ImageSize -> 400]; SelectionMove[EvaluationNotebook[], All, GeneratedCell]; FrontEndExecute[{FrontEnd`SelectionAnimate[0.1]}]; FrontEndExecute[{FrontEndToken["Clear"]}], {t, 0, 15, 0.1}] This works but the cell dividing line flashes on and off spoiling the animation and if there is anything in the cell below this jumps up and down. Is there a proper way of doing this? Hugh Goyder

**RE: Re: Real Time Animation**

**Bug in Solve?**

**RE: Re: Real Time Animation**

**Mathematica 4.1 and MacOSX 10.2**