6
$\begingroup$

Manipulate is, of course, wonderful … but there are LOTS of examples that are simply far too computationally intensive to use live real-time animations for. In such case, one has to use pre-generated graphics. So, let us suppose we have something like:

ListAnimate[
 Table[Plot3D[Cos[x Sin[n y]], {x, 0, 2 Pi}, {y, 0, Pi}], {n, 1, 2, .1}]]

All fine. Then it starts playing … and you grab the plot, and rotate it … and Mma rotates ONE SINGLE plot … and leaves all the others images in the animation as they were … creating a visually absurd animation.

Suggestion: If a user rotates one plot in a grouped animation ... even if they pre-rendered … they should all rotate by the same amount … so the animation will still work as intended.

Any suggestions as to how to overcome this short-coming in the Mma 9 front-end user interface?

$\endgroup$
4
  • 2
    $\begingroup$ Related: mathematica.stackexchange.com/q/5375/131 $\endgroup$
    – Yves Klett
    Jul 19, 2013 at 21:25
  • $\begingroup$ I seem to recall another question about rotating (two) graphics together, but I cannot find it. Does that sound familiar to anyone else? $\endgroup$
    – Mr.Wizard
    Jul 19, 2013 at 21:33
  • 2
    $\begingroup$ @Mr.Wizard this one? $\endgroup$
    – Kuba
    Jul 19, 2013 at 21:40
  • $\begingroup$ @Kuba yes, I believe so; thanks! $\endgroup$
    – Mr.Wizard
    Jul 20, 2013 at 3:46

2 Answers 2

6
$\begingroup$

You can create plots with Dynamic ViewMatrix components.

However, it cancels advantage of light 2D rendered graphics. But that's your wish, isn't it? Of course it is still better than dynamic updating whole Plots.

va = 60 Degree;
vp = {1, 1, 1};
vv = {0, 0, 1};
plot = Table[Plot3D[Cos[x Sin[n y]], {x, -1, 1}, {y, -1, 1},
              ImageSize -> 300, SphericalRegion -> True, PlotRange -> 1, 
              BoxRatios -> 1,
              ViewAngle -> Dynamic@va, ViewPoint -> Dynamic@vp, 
              ViewVertical -> Dynamic@vv],
            {n, 1, 2, .1}];

ListAnimate[plot]

enter image description here

$\endgroup$
3
  • $\begingroup$ That's a very clever suggestion ... but all the plots go a bit 'weird' after you grab one of them. I tried controlling this by setting BoxRatios -> {1, 1, 3}, which partly helped, but still compacted the resulting plots into a small box. $\endgroup$
    – wolfies
    Jul 19, 2013 at 20:48
  • $\begingroup$ @wolfies I must admit I can not handle ViewMatrix :) take a look at an update. $\endgroup$
    – Kuba
    Jul 19, 2013 at 21:00
  • $\begingroup$ @wolfies does putting Kuba's dynamic settings within the Manipulate help: ListAnimate[ Table[Plot3D[Cos[x Sin[n y]], {x, 0, 2 Pi}, {y, 0, Pi}, ViewAngle -> Dynamic@va, ViewPoint -> Dynamic@vp, ViewVertical -> Dynamic@vv], {n, 1, 2, .1}], Initialization :> (va = 60 Degree; vp = {1, 1, 1}; vv = {0, 0, 1};)] $\endgroup$ Jul 20, 2013 at 2:46
4
$\begingroup$

The key is to separate the graphics from the view properties, each with its own Dynamic wrapper. That way the view properties are updated by the front end independently from the Graphics3D data being updated from the kernel.

This can't be done with ListAnimate (or at least I don't see how at this point). Every time a new graphic is presented by ListAnimate, the Dynamic view properties are recreated, interrupting the updating by the front end.

However, if we use Animate, we can update the graphics elements separately from the view options. This lets the view properties be updated continuously and the graphics rotate smoothly.

DynamicModule[{vp, vv, va, plots},
 va = 35 Degree;
 vp = {1.3, -2.4, 2};
 vv = {0, 0, 1};
 plots = Table[
    Plot3D[Cos[x Sin[n y]], {x, -1, 1}, {y, -1, 1}, 
      PlotRange -> {0, 1}, SphericalRegion -> True, 
      ViewAngle -> Dynamic@va, ViewPoint -> Dynamic@vp, 
      ViewVertical -> Dynamic@vv],
  {n, 1, 2, .1}];

 Animate[Graphics3D[Dynamic@First@plots[[n]], 
   Options@First@plots], {n, 1, Length@plots, 1}]
 ]

Mathematica graphics

$\endgroup$

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.