// (3, [0..3])
// (3.5, [0.2..2.3])
// (4, 1)
+
+ /*
+ On another note:
+ inflection point is always at (2s + e - 3) / (3s + 3e - 6).
+
+ s + e - 2 == 0: no inflection
+
+ s + e > 2:
+ 0 < inflection < 1 if:
+ 0 < 2s + e - 3 < 3s + 3e - 6
+ 2s + e > 3 and 2e + s > 3
+
+ s + e < 2:
+ 0 < inflection < 1 if:
+ 0 > 2s + e - 3 > 3s + 3e - 6
+ 2s + e < 3 and 2e + s < 3
+
+ Therefore: there is an inflection point iff:
+ e outside (3 - s)/2 .. 3 - s*2
+
+ in other words, if (s,e) in triangle (1,1)(0,3)(0,1.5) or in triangle (1,1)(3,0)(1.5,0)
+ */
}
{
case 1: // linear
break;
+ // phasepos = cubic_speedfunc(1, 1, phasepos); // identity
case 2: // cosine
/* old version, good for mathematical reference
phasepos = 3.14159265 + (phasepos * 3.14159265); // range: [pi, 2pi]
phasepos = phasepos / 2; // correct range to [0, 1]
*/
- phasepos = (1 - cos(phasepos * 3.14159265)) / 2;
+ // phasepos = (1 - cos(phasepos * 3.14159265)) / 2;
+ phasepos = cubic_speedfunc(0, 0, phasepos);
break;
case 3: // inverted cosine
- phasepos = acos(1 - phasepos * 2) / 3.14159265;
+ // phasepos = acos(1 - phasepos * 2) / 3.14159265;
+ phasepos = cubic_speedfunc(2, 2, phasepos);
break;
case 4: // half cosine
- phasepos = (1 - cos(phasepos * (3.14159265 / 2)));
+ // phasepos = (1 - cos(phasepos * (3.14159265 / 2)));
+ phasepos = cubic_speedfunc(0, 1.5, phasepos);
break;
case 5: // inverted half cosine
- phasepos = sin(phasepos * (3.14159265 / 2));
+ // phasepos = sin(phasepos * (3.14159265 / 2));
+ phasepos = cubic_speedfunc(1.5, 0, phasepos);
break;
}
nextpos = self.origin + (delta * phasepos) + (delta2 * phasepos * phasepos);