interpolation: smooth means smoothstep, not cosine

Smoothstep[1] is a nice smooth alternative to cosine that
doesn't require special math functons, and should thus be
suitable on more platforms. The cosine-curve and the
smoothstep are very similar, and this change introduces
only a very small error (always less than 1 per cent)
compared to the old result.

Change the smooth curve definition to match this.

[1]: http://en.wikipedia.org/wiki/Smoothstep
This commit is contained in:
Erik Faye-Lund 2010-03-25 00:03:59 +01:00
parent 9f6eeb0b5d
commit a56dc45690

View File

@ -22,7 +22,7 @@ static float key_linear(const struct track_key k[2], double row)
static float key_smooth(const struct track_key k[2], double row)
{
double t = (row - k[0].row) / (k[1].row - k[0].row);
t = (1.0 - cos(t * M_PI)) * 0.5;
t = t * t * (3 - 2 * t);
return (float)(k[0].value + (k[1].value - k[0].value) * t);
}