Message Boards Message Boards

0
|
4275 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Why does Animate not wait for user input data?

Posted 7 years ago

I would like to input a variable using a form and then use that variable in an animation. A simple example is shown in the code below.

Clear["Global`*"]
form = FormFunction["length" -> "Number", # &];
datin = form[];
len = datin[["length"]] // N;
\[Theta][t_] = Sin[2 \[Pi] t];

Animate[Graphics[{Disk[{0, 0}, .15], 
   Disk[{l Sin[.2 \[Theta][t]], -l Cos[.2 \[Theta][t]]}, .15] /. 
    l -> len, 
   Line[{{0, 0}, {l Sin[.2 \[Theta][t]], -l Cos[.2 \[Theta][t]]}}] /. 
    l -> len}, PlotRange -> {{-5, 5}, {-9, 1}}], {t, 0, 10, .01}, 
 AnimationRate -> 1, AnimationRunning -> False]

But it seems that the animated graphic attempts to run as soon as the notebook is executed and results in an error message and the graphic painted pink until the data is entered. Is there some way to keep this error from occurring?

POSTED BY: Mike Luntz

Hmm, it waits for input for me (V11.2, MacOS), then displays a non-running animation after input, and finally runs after I click the play button.

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract