# Random variable in animation - point on Circle, Clockwise or counter-clockwise direction.

Heine Strømdahl shared this question 2 years ago

Hi.

I need a very simple random variable, which is continuously updated, in a simple animation of a movement of a point on the circle periphery. This will enable some random movements around the circle periphery - clockwise or counter-clockwise.

First define T=1, let T go between [0,2π]. Then let (cos(T),sin(T)) and start animation. (Play)

Is it possible to introduce a simple random variable U, which can only take on two values -1 and 1 and which is updated every time the animation starts afresh again from T=0 ?

With (cos(U*T),sin(U*T)) this will produce a random movement clockwise or counter-clockwise.

Thanks.

Heine Stromdahl, Copenhagen 2

Try with something like

```Dummy=0
RandomBetween(0, 1+0*Dummy)*2-1```
and then

```SetValue(Dummy,0)
```
to update it 2

There are 2 Problems:

1. U can only take on two values -1 and 1
2. U is updated If T=0

For 1): SetValue(U, RandomBetween(0,1)*2-1) --> principle from M.Borcherds

For 2):

The speed of a slider must be (about) constant. This means that the position of the slider must occasionally jump to a new position. This means that the slider is very rarely exactly at the position == 0. So the condition T==0 is not true.

Instead of querying for the current value of T, the difference between the current value and the previous value must be tested (current value - previous value < 0)