0
$\begingroup$

Trying to animate a "rocket" accelerating until some time, then braking until it reaches a constant speed. Is there a way to animate this using Piecewise and ListAnimate? Do I need another function?

Plot[Piecewise[{{39, t <= 35}, {2000/(14 + 10 t), 
35 < t < 65}, {3, t >= 65}}], {t, 0, 90}, PlotLabel -> "Velocity vs. time", PlotRange -> All]

ListAnimate[Table[Graphics[{Line[{{0, 0},{0, 3}}],Line[{{0, 0},{12, 0}}],Triangle[{{x, 0}, {x + 1, 1}, {x + 2, 0}}]}],{x, 0, 10}], AnimationRunning -> False, AnimationRate -> 10]

I'm seeing something similar here. What I'm failing to see is HOW different rates are being achieved so I can adapt it to my situation. I.e. do I need to phrase my different-speed regions in terms of position instead of time?

Edit: I have figured out the different rates (by developing functions in terms of position vs. time and setting the coordinates of my object to change piecewise according to these functions) and am now grappling with the issue of trying to see the entire length of the "flight path" and the rocket at the same time. Not sure how else to visually create a sense of speed.

ListAnimate[Table[Graphics[{Line[{{0, 0},{0, 3}}],Line[{{0, 0},{12, 0}}],Triangle[{{Piecewise[{{39, t <= 35}, {2000/(14 + 10 t), 35 < t < 65}, {3, t >= 65}}], 0}, {Piecewise[{{39, t <= 35}, {2000/(14 + 10 t), 35 < t < 65}, {3, t >= 65}}], + 1, 1}, {Piecewise[{{39, t <= 35}, {2000/(14 + 10 t), 35 < t < 65}, {3, t >= 65}}], + 2, 0}}]}],{t, 0, 100}], AnimationRunning -> False, AnimationRate -> 10]
$\endgroup$
  • $\begingroup$ What is taccel and tcollapse. We can't get your code to run correctly without those. $\endgroup$ – march Apr 15 at 18:02

Your Answer

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

Browse other questions tagged or ask your own question.