Re: How to animate?
- To: mathgroup at smc.vnet.net
- Subject: [mg38529] Re: How to animate?
- From: "Borut L" <gollum at email.si>
- Date: Sun, 22 Dec 2002 04:13:56 -0500 (EST)
- References: <au0riv$oo2$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, A similar, but effectively different aproach would be to first generate the frames and then subsequently displaying each new frame and deleting the previous one. It's a solution by Omega Consulting dating 27. februar 2002 7:05 (SUBJECT "Re: Animation in one frame?"). It is always wise to look for past discussion on MathSource. GraphicsCell[gr_] := Cell[GraphicsData["PostScript", DisplayString[gr]],"Graphics"] ReplaceGraphic[gr_] := Module[{nb=EvaluationNotebook[]}, SelectionMove[nb, All, GeneratedCell]; NotebookWrite[nb, GraphicsCell[gr]] ] AnimateInPlace[{first_, rest___}] := (CellPrint[GraphicsCell[first]]; Scan[ReplaceGraphic, {rest}]) try AnimateInPlace[frames1] where frames1 are images created by David Park below. bye, Borut * Excerpt from Park's reply | versus about 13 seconds to produce the set in the first place. So it is not | perfect but maybe it will be good enough - or maybe somebody will suggest a | better method. "David Park" <djmp at earthlink.net> wrote in message news:au0riv$oo2$1 at smc.vnet.net... | Christopher, | | I like this question because now I have learned how to do something new. | | The following function is in the DrawGraphics package at my web site. I copy | it out here for anyone to use. | | DoShow[args1___, DisplayFunction -> _, args2___] := | Show[args1, DisplayFunction -> $DisplayFunction, args2]; | DoShow[args___] := Show[args, DisplayFunction -> $DisplayFunction] | | Now we make the frames for your animation without display. I increased the | number of plot points. It takes a little time. | | frames1 = | Table[ Plot3D[ BesselJ[0, Sqrt[x^2 + y^2] + t], | {x, -10, 10}, {y, -10, 10}, Axes -> False, | PlotPoints -> 30, | PlotRange -> {-0.5, 1.0}, | DisplayFunction -> Identity ], | {t, 0, 8} ]; | | Now we use the following commands to quickly display all the frames, close | them up and run the animation. All the frames are shown for about 1 second | versus about 13 seconds to produce the set in the first place. So it is not | perfect but maybe it will be good enough - or maybe somebody will suggest a | better method. | | DoShow /@ frames1; | SelectionMove[EvaluationNotebook[], All, GeneratedCell] | FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.01]; | FrontEndExecute[{FrontEnd`SelectionAnimate[200, AnimationDisplayTime -> 0.1, | AnimationDirection -> Forward]}] | | The Pause command was included to guarantee that the cell group is closed | before the animation starts. However I find that there is a bug in Pause in | that it always pauses for 1 second even though it should handle smaller time | intervals. | | David Park | djmp at earthlink.net | http://home.earthlink.net/~djmp/ | | From: Christopher R. Carlen [mailto:crcarle at sandia.gov] To: mathgroup at smc.vnet.net | | | Hi: | | I'm using 4.1.0 on Linux | | I have been reading in section 1.9.12 about animating graphics. I don't | seem to be able to get the example to work. | | If I input: | | Table[ Plot3D[ BesselJ[0, Sqrt[x^2 + y^2] + t], | {x, -10, 10}, {y, -10, 10}, Axes -> False, | PlotRange -> {-0.5, 1.0}, | DisplayFunction -> Identity ], | {t, 0, 8} ] // Short | | Then I input: | | ShowAnimation[%] | | Mathematica just outputs: | | ShowAnimation[{\[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator], \ | \[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator], \ | \[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator], \ | \[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator], \ | \[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator], \ | \[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator], \ | \[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator], \ | \[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator], \ | \[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator]}] | | (how do I get it to copy/paste what I see in the notebook, instead of | all the internal cell expression stuff?) | | If I change the example to: | | Table[ Plot3D[ BesselJ[0, Sqrt[x^2 + y^2] + t], | {x, -10, 10}, {y, -10, 10}, Axes -> False, | PlotRange -> {-0.5, 1.0} ], | {t, 0, 8} ] // Short | | Then I get 17 graphics rendered. I can click the cell containing them, | then use Cell|Animate Selected Graphics, which then produces the animation. | | I want to have a command that I can execute interactively or associated | with a button, to animate the graphics. I don't want the graphics | displayed when I execute the command that generates the graphics. | | What is the right way to do this? | | Thanks. | | -- | ____________________________________ | Christopher R. Carlen | Principal Laser/Optical Technologist | Sandia National Laboratories CA USA | crcarle at sandia.gov | | | |