Added the interpolation
float isin(float f)
{
boolean pos = true; // positive
if (f < 0)
{
f = -f;
pos = !pos;
}
long x = f;
unsigned int r = (f-x) * 256;
if (x >= 360) x %= 360;
if (x >= 180)
{
x -= 180;
pos = !pos;
}
if (x >= 90)
{
x = 180 - x;
if (r != 0)
{
r = 256-r;
x--;
}
}
unsigned int v = isinTable16[x];
// interpolate if needed
if (r > 0) v = v + ((isinTable16[x+1] - v)/8 * r) /32;
if (pos) return v * 0.0000152590219; // = /65535.0
return v * -0.0000152590219 ;
}
runtime 45 micros (49 if the interpolation is not conditional) factor 2.6 faster than sine
steps of 0.1 degree
max error: 0.00015676 (factor 55.7 lower than without interpolation
avg error: 0.00004814 (factor 57.7 lower than without interpolation