2
$\begingroup$

I have a parametric function surf[u,v]. It can be plotted successfully like this: ParametricPlot3D[surf[u, v], {u, 0, 6 Pi *0.7}, {v, 0, 2 Pi}]

However, I would like to make a series of plots, incrementally changing umax. I tried this with a for loop as well as table, like this:

nn = 24;
Table[ParametricPlot3D[surf[u,v],{u,0,6 Pi*i/nn},{v,0,2Pi}],{i,1,nn,1}]

Unfortunately, every time I run this, it crashes the Kernel without finishing. I tried running a similar command with a simpler parametric surface, which finishes successfully and without crash:

nn = 24;
Table[ParametricPlot3D[{Cos[u], Sin[u] + Cos[v], Sin[v]}, {u, 0, 
   2 \[Pi] i/nn}, {v, -\[Pi], \[Pi]}], {i, 1, nn, 1}]

So the problem must be with my surface. I am using Mathematica 10.2.0.0 on Linux (64-bit). Here is the full code causing the premature Kernel quit:

surf[u_, v_] := {Cos[
    u] (16.958793136378254` E^(0.16568669119550355` u) + \
(1.2436985521695564`*^-15 + 
        8.299999999999999` E^(0.16568669119550355` u) + 
        0.34091663610461015` Sqrt[
          8.881784197001252`*^-16 + 
           5.927385595690565` E^(0.16568669119550355` u)] Cos[
          0.0027916963719975653` + 
           179.1021065468981` Log[
             1.4984319905657307`*^-16 + 
              1.` E^(0.16568669119550355` u)]]) Sin[v]), 
  Sin[u] (16.958793136378254` E^(0.16568669119550355` u) + \
(1.2436985521695564`*^-15 + 
        8.299999999999999` E^(0.16568669119550355` u) + 
        0.34091663610461015` Sqrt[
          8.881784197001252`*^-16 + 
           5.927385595690565` E^(0.16568669119550355` u)] Cos[
          0.0027916963719975653` + 
           179.1021065468981` Log[
             1.4984319905657307`*^-16 + 
              1.` E^(0.16568669119550355` u)]]) Sin[v]), 
  Cos[v] (8.881784197001252`*^-16 + 
     5.927385595690565` E^(0.16568669119550355` u) + 
     0.24346317568406606` Sqrt[
       8.881784197001252`*^-16 + 
        5.927385595690565` E^(0.16568669119550355` u)] Cos[
       0.002791696372037334` + 
        179.1021065468981` Log[
          1.4984319905657304`*^-16 + 
           0.9999999999999998` E^(0.16568669119550355` u)]])}

nn = 24;
Table[ParametricPlot3D[
  surf[u, v], {u, 0, 6 Pi i/nn}, {v, 0, 2 Pi}], {i, 1, nn, 1}];
$\endgroup$
4
  • $\begingroup$ can you try suppressing the output via ;, assign a name to the plot (e.g. with a For[] loop), and export them instead of displaying them in the notebook? $\endgroup$ Commented Feb 2, 2016 at 10:47
  • $\begingroup$ Try this too: Do[Print@ParametricPlot3D[ surf[u, v], {u, 0, 6 Pi i/nn}, {v, 0, 2 Pi}], {i, 1, nn}] $\endgroup$ Commented Feb 2, 2016 at 10:48
  • $\begingroup$ I apologise, I forgot a semicolon in the crashing code (corrected above). Actually, if I run "Table[...]" it does work and produce the plots, but if I suppress the output with "Table[...];", that is when it crashes! The corrected code above crashes. $\endgroup$ Commented Feb 2, 2016 at 10:55
  • $\begingroup$ Can you try adding a "list=" before Table[] and reduce nn to 1? Then call "list" in a new line. $\endgroup$ Commented Feb 2, 2016 at 11:05

1 Answer 1

1
$\begingroup$

Build a Table of segments and display the desired number of segments.

surf[u_, v_] := {Cos[
     u] (16.958793136378254` E^(0.16568669119550355` u) + \
(1.2436985521695564`*^-15 + 8.299999999999999` E^(0.16568669119550355` u) + 
         0.34091663610461015` Sqrt[
           8.881784197001252`*^-16 + 
            5.927385595690565` E^(0.16568669119550355` u)] Cos[
           0.0027916963719975653` + 
            179.1021065468981` Log[
              1.4984319905657307`*^-16 + 
               1.` E^(0.16568669119550355` u)]]) Sin[v]), 
   Sin[u] (16.958793136378254` E^(0.16568669119550355` u) + \
(1.2436985521695564`*^-15 + 8.299999999999999` E^(0.16568669119550355` u) + 
         0.34091663610461015` Sqrt[
           8.881784197001252`*^-16 + 
            5.927385595690565` E^(0.16568669119550355` u)] Cos[
           0.0027916963719975653` + 
            179.1021065468981` Log[
              1.4984319905657307`*^-16 + 
               1.` E^(0.16568669119550355` u)]]) Sin[v]), 
   Cos[v] (8.881784197001252`*^-16 + 
      5.927385595690565` E^(0.16568669119550355` u) + 
      0.24346317568406606` Sqrt[
        8.881784197001252`*^-16 + 
         5.927385595690565` E^(0.16568669119550355` u)] Cos[
        0.002791696372037334` + 
         179.1021065468981` Log[
           1.4984319905657304`*^-16 + 
            0.9999999999999998` E^(0.16568669119550355` u)]])};

nn = 24;

segments = Table[
   ParametricPlot3D[
    surf[u, v],
    {u, 6 Pi (i - 1)/nn, 6 Pi i/nn}, {v, 0, 2 Pi},
    PlotRange ->
     {{-360, 580}, {-460, 460}, {-150, 150}}],
   {i, nn}];

Manipulate[
 Show[segments[[1 ;; m]]],
 {{m, 24}, 1, nn, 1, ControlType -> Setter}]

Animate[
 Show[segments[[1 ;; m]]],
 {{m, 1}, 1, nn, 1},
 AnimationRate -> 1.25,
 AnimationDirection -> ForwardBackward]
$\endgroup$
2
  • 1
    $\begingroup$ Thank you Bob, this seems to work flawlessly (and I can't quite explain why). However, what I am really aiming for is an animation with very detailed surface plots, such that the rendering may take a minute per frame, for hundreds of frames. My idea was to use the Export[] command to create hundreds of numbered png's. This is why I would prefer a truly sequential treatment, rather than leaving hundreds of detailed surfaces in memory. Plotting truly sequentially seems to fail, no matter if I use Table (like in my original post) or similarly a For loop. $\endgroup$ Commented Feb 2, 2016 at 22:02
  • $\begingroup$ See How to | Import and Export Animations. The Manipulate above (built from segments) can be exported directly. $\endgroup$
    – Bob Hanlon
    Commented Feb 3, 2016 at 0:52

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.