2
$\begingroup$

I'm trying to display some graphs, which were defined with plot above this line of code. The parametric plot moves through all of the x values, the others are stationary. I would like the parametric plot to pause at a specific value (x = 14.9475). Any ideas? Perhaps nesting the following code inside of a Dynamic or Manipulate.

Animate[
  Show[
    Hill, Antsight, BladeofGrass, 
    ParametricPlot[{x + a, Hillheight[x] + a Derivative[1][Hillheight][x]}, {a, 0, 32}], 
    PlotRange -> {{0, 35}, {0, 10}}], {x, 0, 32}]

So far I've been playing around with this.

Do[{Animate[
   Show[{Hill, Antsight, BladeofGrass, 
     ParametricPlot[{x + a, 
       Hillheight[x] + a Derivative[1][Hillheight][x]}, {a, 0, 32}]}, 
    PlotRange -> {{0, 35}, {0, 10}}], {x, 0, 32}]}, 
 If[x == 14.9475, Break[]];
 Pause[0.2], {x, 0, 32, 0.1}]

Heres the rest of the code.

Hillheight[x_] := (1/16 x^2 - 2 x + 80)/(1/16 x^2 - 2 x + 20)^2
Hill = Plot[(1/16 x^2 - 2 x + 80)/(1/16 x^2 - 2 x + 20)^2, {x, 0, 32},Filling -> Bottom, PlotStyle -> Brown]

BladeofGrass = ParametricPlot[{32, 1/5 + y}, {y, 0, 39/5}, PlotStyle -> {Green}]
Antsight = ListLinePlot[{{32, 8}, {14.9475, Hillheight[14.9475]}}, {PlotStyle ->
         Dashed}]
$\endgroup$
3
$\begingroup$

It's difficult to help you out without having definitions for your various graphs. If I understand your question, you want to pause an Animator at a particular spot. Here's a proof of concept example:

DynamicModule[{i, t},
 Column@{Animator[Dynamic[i], {0, 10}, 
    AnimationTimeIndex -> Dynamic[t]], 
   Dynamic@Plot[Sin[x + i], {x, 0, 10}],
   Dynamic@If[1.90 < t < 2.00, (Pause[1]; t = 2;), ""]
   }]

enter image description here

I create my own Animate so I can capture the value of AnimationTimeIndex (which was introduced in v10, so this won't work in earlier versions). The DefaultDuration is set to 5 seconds so I stop the animation at 40% through, pause for a second, and restart close to that point.

You'll note that there are some kinks to work out. For reasons not known to me, setting my dynamic t to 2 after the pause does not seem to set AnimationTimeIndex properly. Also, not shown in the animated gif is an ugly nested If statement that shows up upon Initialization (and goes away pretty quickly). Lastly, note that there are 3 rows in the column; the If statement must print something in order for this to work. I have it printing "".

$\endgroup$
  • $\begingroup$ Hopefully the added code helped some, is there any way to set it to pause at an x-coordinate though? even if you could enter any value $\endgroup$ – mentorship Feb 18 '15 at 5:54
  • $\begingroup$ I will try to update with your code when I get a chance. To answer the 2nd part of your question, I think the answer is yes, since teh DefaultDuration is 5 s, so a particular x value would appear at (xmax-xmin)/5 where xmax and xmin are the end/start values in the Animate. $\endgroup$ – bobthechemist Feb 18 '15 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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