Time recording (STUDENT TEMPLATE)

[color=#0000ff][i][color=#0000ff][i][color=#999999]This activity belongs to the GeoGebra book [url=https://www.geogebra.org/m/mes4bgft]The Domain of the Time[/url].[/color][/i][/color][/i][/color][br][br]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.[br][br]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 [img]https://www.geogebra.org/resource/yxbcmb2f/CZJZaLQBirTUHVXU/material-yxbcmb2f.png[/img].[br][br][color=#cc0000]The undisputed star of all simulations will be the script associated with an animated slider. We will call this slider "[b]anima[/b]," which we will create [b]from 0 to 1, with an increment of 0.001[/b].[/color][br][br][b]TIME RECORDING[/b][br][br]We will take the real time from your device's clock at an initial moment [i]t0[/i] and, periodically, the slider "[b]anima[/b]", in PERPETUAL MOTION (hence the title of this presentation), will take the time again at a moment [i]t1[/i]​. We will call [i]tt[/i] the last recorded moment and [i]dt[/i] 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 [i]t0[/i]​.[br][br]To do this, we create the variables we will use with the following initial values:[br][br][b][b] t0[/b][/b] = {0, 0, 0} [b] [br] t1[/b] = {0, 0, 0} [b][b] [br] tt [/b][/b]= 0[b][b] [br] dt[/b][/b] = 0[b][br] t[/b] = (t1(3) < t0(3)) * 3600 + (t1(3) - t0(3)) * 60 + t1(2) - t0(2) + (t1(1) - t0(1)) / 1000 [br][br][list][*][color=#0000ff]t[/color] records the elapsed seconds.[/*][*][color=#0000ff]dt[/color] 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 [b]anima[/b].[/*][/list][br][b]BUTTON [img]https://www.geogebra.org/resource/yxbcmb2f/CZJZaLQBirTUHVXU/material-yxbcmb2f.png[/img][/b][br]We create the button [img]https://www.geogebra.org/resource/yxbcmb2f/CZJZaLQBirTUHVXU/material-yxbcmb2f.png[/img] with the following script "On Click", which takes the initial time {[i]milliseconds[/i], [i]seconds[/i], [i]minutes[/i]} and assigns it to [i]t0[/i] and [i]t1[/i]​. Immediately, it activates the slider [b]anima[/b].[br][br][color=#0000ff] SetValue(t0, First(GetTime(), 3))[br] SetValue(t1, t0)[br] StartAnimation(anima, true)[/color][br][br][b]SCRIPT FOR SLIDER "anima[/b]"[br][br]In the slider [b]anima [/b]we write the following script "on update," which updates [i]t1[/i] and records the elapsed seconds ([i]dt[/i]) since [i]tt[/i]:[br][br] [color=#cc0000] # Calculate the elapsed seconds dt; add one second if t1(1) < tt[/color][br][color=#0000ff] SetValue(tt, t1(1))[br] SetValue(t1, First(GetTime(), 3))[br] SetValue(dt, (t1(1) < tt) + (t1(1) − tt)/1000)[/color][br][b][br]BUTTON [img]https://www.geogebra.org/resource/hwdawgnn/MmhoDfF5M6lNH9D4/material-hwdawgnn.png[/img][/b][br][br]Finally, we create the [b][img]https://www.geogebra.org/resource/hwdawgnn/MmhoDfF5M6lNH9D4/material-hwdawgnn.png[/img] [/b]button with the following script "On Click":[br][color=#0000ff][br] SetValue(anima, 0)[br] StartAnimation(anima, false)[br] SetValue(t0, {0,0,0})[br] SetValue(t1, t0)[/color]
[b]SCRIPT FOR SLIDER "anima[/b]"[br][br][color=#cc0000]# Calculate the elapsed seconds dt; add one second if t1(1) < tt[/color][br][color=#0000ff]SetValue(tt, t1(1))[br]SetValue(t1, First(GetTime(), 3))[br]SetValue(dt, (t1(1) < tt) + (t1(1) [color=#0000ff]−[/color] tt)/1000)[/color][br] [br] [br][br][br][color=#999999][color=#0000ff][color=#0000ff][color=#999999][color=#999999]Author of the activity and GeoGebra construction: [/color][/color][/color][color=#0000ff][color=#999999][color=#999999][url=https://www.geogebra.org/u/rafael]Rafael Losada[/url].[/color][/color][/color][/color][/color][br]

Information: Time recording (STUDENT TEMPLATE)