37
$\begingroup$

Note: Cross-posted at Wolfram Community

I want to include a Mathematica animation in PowerPoint presentation. My code is:

poskus = Manipulate[
  Graphics3D[
   Dynamic@{{GrayLevel[.3], Line[space[[1 ;; t]]]}, {Blue, 
      PointSize[.015], Point[space[[t]]]},}, Axes -> True, 
   AxesStyle -> Directive[FontSize -> 20, FontFamily -> "Helvetica"], 
   AxesLabel -> {"x [nm]", "y [nm]", "z [nm]"}, 
   BoxRatios -> {1, 1, 1}, ImageSize -> 700, 
   BoxStyle -> Directive[Dashed, Thick], 
   PlotRange -> {{-2620, 1600}, {-1700, 1450}, {-3500, 350}}, 
   SphericalRegion -> True], 
  Row[{Control[{t, 1, Length[data], 1, Animator, ImageSize -> Small, 
      AnimationRunning -> False, AnimationRate -> 50, 
      AnimationRepetitions -> 1}], Spacer[10], 
    Dynamic["time = " <> ToString[data[[t, 1]]]]}], FrameMargins -> 0]

I want to place the animation into the PowerPoint slide so that the first frame is shown. Then I want to start it by mouse click. It should stop in the end position and wait for my next mouse click (for next slide). How can I achieve it?

The best I could get was when exporting to swf. But the problem is that it runs immediately after I reach the slide. And it doesn't stop at the end, but it goes in reverse direction and then forward ... It is also very fast. And my computer becomes slow. The file size (test.swf) is 146 KB.

Some things I would like to know:

  • How to export without the sliders showing
  • which format best to use
  • how to influence the frame rate, length and direction of the animation
  • how to most conveniently integrate the animation into PowerPoint

Edit

Sample of my data: first column is time multiplied by a factor, the others are coordinates.

data={{0.146, -160.582, 125.712, 20.1735}, {0.288, -192.582, 182.712, 
  58.1735}, {0.431, -207.582, 237.712, 201.174}, {0.576, -250.582, 
  134.712, 162.174}, {0.723, -234.582, 226.712, 
  292.174}, {0.877, -259.582, 236.712, 175.174}, {1.02, -303.582, 
  241.712, 61.1735}, {1.16, -362.582, 282.712, 
  17.1735}, {1.3, -448.582, 268.712, 114.174}, {1.45, -309.582, 
  188.712, 87.1735}, {1.58, -275.582, 193.712, 
  31.1735}, {1.73, -142.582, 182.712, -67.8265}, {1.88, -296.582, 
  257.712, -41.8265}, {2.02, -412.582, 
  307.712, -80.8265}, {2.16, -389.582, 
  366.712, -119.826}, {2.31, -337.582, 
  402.712, -273.826}, {2.46, -470.582, 
  499.712, -179.826}, {2.6, -432.582, 
  546.712, -208.826}, {2.76, -386.582, 
  539.712, -339.826}, {2.9, -467.582, 
  429.712, -377.826}, {3.05, -479.582, 
  462.712, -338.826}, {3.18, -514.582, 
  383.712, -239.826}, {3.32, -592.582, 
  279.712, -169.826}, {3.46, -574.582, 
  313.712, -134.826}, {3.61, -575.582, 
  262.712, -198.826}, {3.74, -542.582, 
  269.712, -241.826}, {3.89, -570.582, 
  201.712, -179.826}, {4.04, -637.582, 
  156.712, -128.826}, {4.19, -784.582, 155.712, 
  30.1735}, {4.33, -837.582, 212.712, 31.1735}, {4.48, -750.582, 
  144.712, -121.826}, {4.62, -858.582, 110.712, 
  58.1735}, {4.76, -880.582, 41.7125, -70.8265}, {4.89, -884.582, 
  117.712, -171.826}, {5.04, -874.582, 
  56.7125, -209.826}, {5.2, -924.582, -11.2875, -228.826}, {5.35, \
-896.582, -38.2875, -270.826}, {5.5, -869.582, -44.2875, -317.826}, \
{5.64, -915.582, -132.288, -221.826}, {5.8, -971.582, -51.2875, \
-349.826}, {5.94, -992.582, -95.2875, -377.826}, {6.08, -1060.58, \
-5.2875, -266.826}, {6.23, -1054.58, 
  3.7125, -431.826}, {6.38, -1099.58, 
  31.7125, -505.826}, {6.53, -1211.58, 
  85.7125, -477.826}, {6.68, -1203.58, 
  108.712, -508.826}, {6.83, -1001.58, 
  67.7125, -649.826}, {6.98, -1051.58, -1.2875, -675.826}}
$\endgroup$
12
  • $\begingroup$ There used to be a commercial product M for ActiveX from Episoft that allowed the inclusion of M in PP. Don't know if it's still around. $\endgroup$ Sep 1, 2013 at 19:27
  • 1
    $\begingroup$ Related to the SWF speed concerns: mathematica.stackexchange.com/questions/16107 $\endgroup$ Sep 1, 2013 at 21:09
  • 1
    $\begingroup$ Adding to @Vitaliy Kaurovs suggestions, I can recommend MP4 (.mov) animations, the export of which is described here: mathematica.stackexchange.com/a/4236/131 . These work nicely in PowerPoint, offer the full color range and even display basic play/pause controls on mouseover. $\endgroup$
    – Yves Klett
    Sep 1, 2013 at 21:09
  • 1
    $\begingroup$ Please do format your data in a useable form (e.g. as a list with the correct structure). Think: How would I like a question to look like to make me want to spend time to answer? $\endgroup$
    – Yves Klett
    Sep 4, 2013 at 16:04
  • 1
    $\begingroup$ I edited your question to make it easier to browse. Since it seem you also posted the same question on Wolfram Community, it is a good idea to include this information in your question to avoid redundancy. $\endgroup$
    – Yves Klett
    Sep 5, 2013 at 7:17

2 Answers 2

15
$\begingroup$

My preferred embedding option is to export to MP4 Quicktime (.mov). Taking a few bovine lines from the 2012 Oneliner competition:

{g, p} := {ExampleData@{"Geometry3D", "Cow"}, g[[1, 2, 1]]};
ani = Table[
   g /. g[[1, 2, 3]] -> VertexColors -> (Hue@Random[] & /@ p) /. 
    p -> (# (x - (1 - x)/Sqrt[#.#]) & /@ p), {x, 0, 1, .01}];    
framerate = 10;

ListAnimate[ani, framerate, AnimationRepetitions -> 1] (*preview*)

Mathematica graphics

Now for exporting (note the direct export of the separate frames):

 Export["mooo.mov", ani, "VideoEncoding" -> "MPEG-4 Video", "FrameRate" -> framerate]

("mooo.mov")

The resulting movie imports and embeds nicely into PowerPoint (via Insert->Video->Video from file), and you get the full set of play/pause... controls during animation, see e.g. this screenshot:

Mathematica graphics

You can also use all kinds of PPT format mumbo-jumbo:

Mathematica graphics

Your code has some other issues too, but with slight modifications this seems to work:

frames = Table[
   Graphics3D[{{GrayLevel[.3], Thick, Line[space[[1 ;; t]]]}, {Blue, 
      PointSize[.015], Point[space[[t]]]},}, Axes -> True, 
    AxesStyle -> Directive[FontSize -> 20, FontFamily -> "Helvetica"],
     AxesLabel -> {"x [nm]", "y [nm]", "z [nm]"}, 
    BoxRatios -> {1, 1, 1}, ImageSize -> 700, 
    BoxStyle -> Directive[Dashed, Thick], 
    PlotRange -> {{-2620, 1600}, {-1700, 1450}, {-3500, 350}}, 
    SphericalRegion -> True], {t, 1, Length[space]}];

Export["test.mov", frames, "VideoEncoding" -> "MPEG-4 Video", 
 "FrameRate" -> 1]
$\endgroup$
6
  • $\begingroup$ If I export it to MP4 Quicktime the controls (slider) are there. It is not the same as in your example ... $\endgroup$
    – Luka
    Sep 4, 2013 at 13:41
  • $\begingroup$ @Luka to be expected - why not generate a set of frames (like shown above) and export those? $\endgroup$
    – Yves Klett
    Sep 4, 2013 at 13:42
  • $\begingroup$ I don't know how to create a set of frames from 3D data (x, y, z coordinates), because I also need "the pointer"- a ball that is showing the path. I want to show the random walk of an electron, so the location of the electron must be shown through all the animation. $\endgroup$
    – Luka
    Sep 4, 2013 at 13:46
  • 1
    $\begingroup$ @Luka Your Manipulate already works. You take the Graphics3D part of that and generate t values e.g. in a Table to get your frames. But without your example working helping you is difficult. $\endgroup$
    – Yves Klett
    Sep 4, 2013 at 14:06
  • 1
    $\begingroup$ @Luka Try installing an appropriate QuickTime player, that worked for me in several cases. $\endgroup$
    – Yves Klett
    Sep 4, 2013 at 19:26
28
$\begingroup$

Read comments to your post - many good links there. Additionally, are a few thoughts on the topic.

1) Avoid PPT, - use built-in Mathematica slideshow templates, they were recently updated and are beautiful. Advantage is - you preserve computations and native graphics (like rotations in 3D, etc.). You can read more in this post: Best way to give presentations with Mathematica

2) If you must use PPT, then Export to .GIF file. I see you tried .SWF, this may work too, but you had some problems. Here are solutions with .GIF file

3) The last exotic option is to make a CDF file, embed it into a web page and then use LiveWeb ( tutorial ) to display the webpage in PPT. Very experimental, no guarantees, I did not try it myself.

$\endgroup$
9
  • 3
    $\begingroup$ Thank you very much. Now I need some time to go through all the suggestions and find the one which fits my needs the best. $\endgroup$
    – Luka
    Sep 2, 2013 at 5:51
  • $\begingroup$ GIF has the advantage that animated gifs are actually embedded in ppt. For Any other format ppt links to an external file, resulting in unending headaches should you ever move your files around. The downside to the gif is that it just plays with no control even to pause etc. $\endgroup$
    – george2079
    Sep 3, 2013 at 20:51
  • $\begingroup$ The ppt works fine with imported swf. It is fast .. $\endgroup$
    – Luka
    Sep 3, 2013 at 21:03
  • $\begingroup$ @george2079 movs are also embedded. The onyl issue is that you need e.g. the correct quicktime player (32/64bit etc.). $\endgroup$
    – Yves Klett
    Sep 4, 2013 at 11:28
  • 1
    $\begingroup$ I didn't try with LiveWeb, but I can confirm that a WebBrowser object will display a functioning CDF embedded into a web page. $\endgroup$ Sep 4, 2013 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.