Bubble Animation : Speed of Movement & Rate of Generation

Author:
Lew W. S.

Introduction

This example is made to help intermediate users who wish to do animation (movement) of objects eg. points (can easily apply to other objects where points are used to determine positions), and also control the rate of generation(and appearance) of instances of the objects, understand some of the difficult concepts and tricks better. (Note : Refer to https://www.geogebra.org/m/Chsu6yEg on simulating the generation of instances of bubbles appearing using poisson process, 16 Nov 2017) Try the animation below. Download a copy and access the Geogebra scripts within the objects to understand the commands and parameters used. There is insufficient space to explain every detail here so do refer to the Geogebra Manual and search for the Geogebra objects, commands list, and scripting tutorial and references

Primer on Geogebra animations (Updated on 13 Nov)

In Geogebra animation, when using the number or angle object (with slider) to animate, a crucial point to note is that the "animation speed" is a rate per cycle and not per unit time. When animation speed is set to 1, the duration to complete one cycle (animating from minimum value to maximum value, with some increment) is approximately 13 seconds on a laptop with Intel Core I7 CPU. (There may be variation in this real time duration for different PC/laptops) Note that this duration is independent of the minimum, maximum or increment (unless set to zero or logically not required to increment, eg max = min ). For example if object r's minimum is 0 and maximum is 15, changing increment from 0.1 up to 15 will not change the time taken form r to change from 0 to 15, which is constant 13 seconds for the same laptop. If the minimum is set to 10 and maximum set to 100, irregardless of the increment, the real time taken for r to increase from 10 to 100 is still 13 seconds. To summarize the crucial point from above, animation speed is a rate per cycle. The standard speed of 1 means it takes approximately 13 seconds to animate from mini to max value once. The duration of a cycle (from min to max value), which I denote here as T, is inversely proportional to the animation speed (denoted as S). Hence in the standard case when S =1 , T = 13 also means that T = 13/S. So when speed S = 2, the time taken would be 13/2 = 6.5 seconds. A side point to note is that an animated object may require to be at constant speed or variable speed. S can be made dynamic using algebraic expressions instead of numerical constants. The next thing to note is the generation of the instances of bubbles. The rate at which bubbles are generated and appear on screen are actually controlled via separate animation. With reference to the example, the rate at which the bubbles are required to appear (r_b) can be adjusted through a number slider, which then feeds into the animation speed of another number slider. The second number slider (r) , when animated, counts whole numbers, at a rate equivalent to the required real time. (updated 13 Nov - The value for duration to complete one cycle (from min to max value), T was adjusted to 13s instead of 14s previously indicated, para 1, 2, 3 revised)

How do you do this ?

Notes on Bubble Animation along path : “Speed of travel” & “Rate of Generation” 1. Animation speed (GGB) : Value of 1 is approximately 13 seconds to complete 1 cycle. The speed here refers to how fast one cycle is. And it is proportional to the time taken When value is 2, it takes about 6.5 seconds per cycle. When value is 4, time taken is 3.25 seconds per cycle 2. Note the min and max or increment does not affect the cycle speed but if the position of object depends on min and max then the difference betw min and max if great, implies that the object travels faster if the cycle speed is increased. 3. In this simulation, r_b is used to input the number of bubbles to be generated per minute r is set to count numbers automatically when animated, at a cycle speed of 13*r_b / 900 How is the speed of r obtained ? If there are r counts per cycle and each cycle is 13 seconds for simulation speed S = 1, Real time per cycle = 13/S If each cycle has r counts, then each count = 13/S)/r seconds. So there will be 60/((13/S)/r) counts per minute. We want to simulate r_b counts per minute real time Hence r_b = 60/((13/S)/r) -------------- Eqn (1) Expressing required simulation speed S in terms of r_b counts per minute, and with r count per cycle = 15, from Eqn (1): (13/S)/15 = 60/r_b 13/S = 60*15/r_b S = 13*r_b/900 (Updated 13 Nov to change duration of T to be 13 seconds when S = 1)
4. r is used as a counter to release bubbles U1 and U2. The bubbles to be generated per minute, r_b, affects the counting speed of r (S = 13*r_b/900) and hence the release of the bubbles. 5. n_1 and n_2 are path parameters for U1 & U2 respectively, which are defined as points on segment f, using U1 = Point[f], U2 = Point[f]. Path parameters n_1 and n_2 each have been set to animate with constant speed of 2 (abt 7 seconds real time) Bubbles rise up at a constant speed. As n_1 & n_2 updates, the script commands U1 = Point[f,n_1], U2 = Point[f,n_2] will move U1, U2 along the path of segment f. Change this animation speed if you require a different visual impact of the speed of object Animations are set as “Increasing once” ie. U1 and U2 will stop at end point, and wait to be triggered to move again from start point, once r is updated by increment of 1 If r is odd - U1 restarts, if r is even U2 restarts. Checking r odd or even is achieved using : Mod(r,2) when r is odd returns the value 1, and gives 0 when r is even The script below for animation is found in the OnUpdate section in object r. SetValue[n_1,If[Mod[r,2]>0,If[anim,If[n_1>0&&n_1<0.99,n_1,0],n_1],n_1]] StartAnimation[n_1,true] SetValue[n_2,If[Mod[r,2]<1,If[anim,0,n_2],n_2]] StartAnimation[n_2,true] For Increasing Once animations, even when StartAnimation is set true, if the value is already at maximum, then animation ends there and does not restart. The values need to be reset to less than the maximum value for the animation to start.
6. Button button1 is used to start animation of bubbles via animation of counter r. The script in button1 On Click is : SetValue[anim,!anim] SetCaption[button1,If[anim,“Stop Bubbles' Animation”,“Animate Bubbles U1 & U2”]] StartAnimation[r,anim] SetValue[r,If[anim,1,r]] StartAnimation[n_1,anim] StartAnimation[n_2,anim]