- Ryan Hirst
Smooth interpolation between two values. It is disorienting when points jump from one place to another. To demonstrate particular cases of a problem, it is more descriptive to animate the figures smoothly from position to position. _____ Interpolating with GGBscript →1. Control flow. Straight lines. 2. Rotation: http://www.geogebratube.org/material/show/id/106518
NOTES INTERPOLATION: Linear interpolation is a simple percent: Position = (1-k) Start + k End, Then let k go from 0 to 1. The position goes from Start to end at a constant speed. the value of k is the percent of the journey travelled. But there is no such thing as motion of this kind. The trouble is at the start and end. A more natural interpolation mimics acceleration: starts slow, speed up in the middle, then slows to a halt at the end. Rather than implement complex functions or accurate differentials in the update script, I use the same Linear interpolation, and mix the Current Position with the Start position. I find 50/50 a good mix. This takes care of the smooth transition at the end. But what about the beginning? Perhaps I can massage the interpolation a bit, and get the properties I want . . .(more to come) __________ SCRIPT: Consider point A, which will change position. I need two extra points: : the start value of A : End value Some control flow is necessary. I used these parameters: anim (true/false): the animation is currently running. kprev (true/false): the previous value of k. loop (true/false): the amination has looped past 1. AButton to serve as a trigger. I want to meet these conditions:
- Unless the animation is playing, A0 should follow A. In the update script of A: If[¬anim, SetValue[A0, A]]
- Updates to the worksheet should not trigger the animation. In the update script of k, each SetValue line reads If[anim, SetValue[....]]
- The animation must stop.
- There should be an event trigger. IMO, we have a broken relationship to events in GGB. Lacking a good way (i.e. an event interface... more power, fewer methods) to get information about the user, we need artificial triggers. There are two fairly neutral ways: Buttons and GetTime (more later). Here, I use a button. Then, as the worksheet develops, I will try to offload the button script to detectable events in the worksheet.