Message Boards Message Boards

Avoid backward direction in exporting an animation to avi?

Posted 8 years ago

I would like to export an animation that goes through one cycle in the forward direction. But I can not seem to avoid a cycle forward and backward. An example of what happens is in the avi file generated by this code. I am using Animate here, but the same thing happens with Manipulate.

In[136]:= Clear["Global`*"]

In[137]:= manObjTest = 
 Animate[Plot3D[
   Cos[\[Pi] (x^2 + y^2)/2] Sin[2 \[Pi] t], {x, y} \[Element] Disk[], 
   PlotRange -> {{-1, 1}, {-1, 1}, {-1.5, 1.5}}], {t, 0, 1, .025}, 
  AnimationRunning -> False, AnimationDirection -> Forward]

Out[137]= Manipulate[Plot3D[Cos[Pi*((x^2 + y^2)/2)]*Sin[2*Pi*t], 
   Element[{x, y}, Disk[]], PlotRange -> {{-1, 1}, {-1, 1}, {-1.5, \
1.5}}], 
  {{t, 0.17500000000000002}, 0, 1, 0.025, AnimationRunning -> False, 
   AnimationDirection -> Forward, AppearanceElements -> 
    {"ProgressSlider", "PlayPauseButton", "FasterSlowerButtons", 
     "DirectionButton"}}, ControlType -> Animator, 
  AppearanceElements -> None, DefaultBaseStyle -> "Animate", 
  DefaultLabelStyle -> "AnimateLabel", SynchronousUpdating -> True, 
  ShrinkingDelay -> 10.]

In[139]:= Export["mytest1.avi", manObjTest]

Out[139]= "mytest1.avi"

Has anyone else had this problem?

Edit: When I looked at the code that I copied to this post it does not look like the notebook. I don't know if that is significant. The code in the animate function actually appears as

manObjTest = 
 Animate[Plot3D[
   Cos[\[Pi] (x^2 + y^2)/2] Sin[2 \[Pi] t], {x, y} \[Element] Disk[], 
   PlotRange -> {{-1, 1}, {-1, 1}, {-1.5, 1.5}}],{t,0,1,.025},AnimationRunning -> False, AnimationDirection -> Forward]
POSTED BY: Mike Luntz

There may be a "cleaner" way to do this, but from a practical standpoint you can just limit the range of your Sin function to [0,Pi) and create individual plots for a discrete values os "t" that you can later export as a list of images:

toexport = 
 Table[Plot3D[
   Cos[\[Pi] (x^2 + y^2)/2] Sin[t], {x, y} \[Element] Disk[], 
   PlotRange -> {{-1, 1}, {-1, 1}, {-1.5, 1.5}}], {t, 0, Pi, 0.025}]

Export["mytest1.avi", toexport]
POSTED BY: massimo fazio
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract