Google Classroom
GeoGebraGeoGebra Classroom

Time recording (STUDENT TEMPLATE)

This activity belongs to the GeoGebra book The Domain of the Time. We will see how we can take advantage of the passage of time and vectors to perform physics simulations without the need to resort to differential calculus or trigonometry and with (almost) no use of formulas. This may slightly reduce accuracy, but it increases simplicity and versatility. To achieve this, the first thing we need to do is collect the time from the computer (or other device we are using) and use it to count the time that elapses from when we press the button . The undisputed star of all simulations will be the script associated with an animated slider. We will call this slider "anima," which we will create from 0 to 1, with an increment of 0.001. TIME RECORDING We will take the real time from your device's clock at an initial moment t0 and, periodically, the slider "anima", in PERPETUAL MOTION (hence the title of this presentation), will take the time again at a moment t1​. We will call tt the last recorded moment and dt the time difference (a few hundredths of a second) between these time recordings. The variable ttt will store the total time, in seconds, elapsed since t0​. To do this, we create the variables we will use with the following initial values:  t0 = {0, 0, 0} t1 = {0, 0, 0}  tt = 0  dt = 0 t = (t1(3) < t0(3)) * 3600 + (t1(3) - t0(3)) * 60 + t1(2) - t0(2) + (t1(1) - t0(1)) / 1000
  • t records the elapsed seconds.
  • dt will store the value (t1(1) < tt) + (t1(1) − tt)/1000, which collects the FRACTION OF A SECOND ELAPSED between two executions of the script for the slider anima.
BUTTON We create the button with the following script "On Click", which takes the initial time {milliseconds, seconds, minutes} and assigns it to t0 and t1​. Immediately, it activates the slider anima. SetValue(t0, First(GetTime(), 3)) SetValue(t1, t0) StartAnimation(anima, true) SCRIPT FOR SLIDER "anima" In the slider anima we write the following script "on update," which updates t1 and records the elapsed seconds (dt) since tt: # Calculate the elapsed seconds dt; add one second if t1(1) < tt SetValue(tt, t1(1)) SetValue(t1, First(GetTime(), 3)) SetValue(dt, (t1(1) < tt) + (t1(1) − tt)/1000) BUTTON Finally, we create the button with the following script "On Click": SetValue(anima, 0) StartAnimation(anima, false) SetValue(t0, {0,0,0}) SetValue(t1, t0)
SCRIPT FOR SLIDER "anima" # Calculate the elapsed seconds dt; add one second if t1(1) < tt SetValue(tt, t1(1)) SetValue(t1, First(GetTime(), 3)) SetValue(dt, (t1(1) < tt) + (t1(1) tt)/1000) Author of the activity and GeoGebra construction: Rafael Losada.