I tried to introduce an decay to the rotation of an object in mathematica by tying the animation rate to the degree of rotation as in the picture below and it goes quite smoothly until it reaches a little more than half then it starts spinning uncontrollably the animation rate becomes random. Does anyone know the cause of this bug and how to fix it? And if you know a way to make the animation rate decays please tell me how to do it too thanks.

EDIT: My code is

Animate[Graphics[Rotate[Rectangle[], x Degree]], {x, 0, 360},DefaultDuration -> 360/(360 - x)]
Animate[Graphics[Rotate[Rectangle[], x Degree]], {x, 0, 360}, AnimationRate -> 360 - x]

enter image description here

  • 1
    $\begingroup$ Welcome to MSE. Please edit your question to include the code you are running so it can be copied/pasted and reproduced. $\endgroup$ Nov 23 '21 at 16:25
  • 1
    $\begingroup$ Don't you think 360 is a too high value for AnimationRate? $\endgroup$
    – polfosol
    Nov 23 '21 at 16:49
  • $\begingroup$ @polfosol: Animate[Plot[{Sin[x], Cos[x], t Sin[x] + (1 - t) Cos[x]}, {x, 0, 10}], {t, 0, 1}, AnimationRate -> 360, AnimationRunning -> True] works well. $\endgroup$
    – user64494
    Nov 23 '21 at 18:10
  • 3
    $\begingroup$ The problem relates to changing DefaultDuration within the animation. Adding DefaultDuration -> 1/(1 - t) to the final example in the Animate documentation produces the same problem. Because the documentation does not warn about this, I view the problem as a bug. $\endgroup$
    – bbgodfrey
    Nov 23 '21 at 18:12
  • 2
    $\begingroup$ By the way, Animate[Graphics[Rotate[Rectangle[], x Degree]], {x, 0, 90}, DefaultDuration -> 360/(360 - x)] also produces the same problem. $\endgroup$
    – bbgodfrey
    Nov 23 '21 at 18:14

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.