Now let's do something a little more interesting, switch draw3 on window the 10-minute (day) and change our formula to:
v = math.sin(t * 2 * 3.14 / 3600 / 12)On the screen we see two sine wave. The undoubted progress if in terms of visual appeal. Our new parameter is no longer a horizontal line, its value depends on from time. The secret lies in the use of the variable 't'. it is in this variable, before the formula, the program browsing places the information for which time he wants to get the value of our parameter. Assuming that we have chosen the day, eg 24 November 2012, This would draw a graph looking at the program made a formula parameter 24 * 6 (draw a graph for 24 hours, and for each hour charge 10 minute values), substituting the variable t the time corresponding to 24 November at 00:00 on November 24 at 0:10, November 24 at 0:20, November 24 at 00:30 November 24 at 0:40, November 24 at 0:50, November 24 at 01:00 ..., November 24 at 23:40, 24 November at 23.50.
Time variable t is stored as a number, the number of seconds from a contractual time '0 '. It sounds quite mysterious but in practice, when we write parameters do not need to remember how time is recorded. This example is properly taken into account the representation of the exception because the variable t, so to fit in 24 2 sine wave.
Poprzedni | Spis treści | Następny |
The beginnings. | Początek rozdziału | Average, variable 'pt'. |