I have the following trig functions, but I am wondering if there is a faster algorithm that I could implement:
static const double SINMIN=0.0009999998333333;
static const double COSMIN=0.9999995000000417;
static const double TANMIN=0.0010000003333334;
static const double E=2.718281828459045235360;
static const double PI=3.14159265358979323846;
static const double MINVAL=0.01;
double sin(double ax)
{
double x=aabs(ax);
if (x==MINVAL)
{
switch (quadrant(ax))
{
case 1:
case 2:
return SINMIN;
case 3:
case 4:
return -SINMIN;
}
}
else
return (SINMIN*cos(x-MINVAL)+COSMIN*sin(x-MINVAL));
}
double cos(double x)
{
if (x==MINVAL)
{
switch (quadrant(ax))
{
case 1:
case 4:
return COSMIN;
case 2:
case 3:
return -COSMIN;
}
}
else
return (COSMIN*cos(x-MINVAL)+SINMIN*sin(x-MINVAL));
}
double tan(double x)
{
if (x==MINVAL)
{
switch (quadrant(ax))
{
case 1:
case 3:
return TANMIN;
case 2:
case 4:
return -TANMIN;
}
}
else
return ((TANMIN+tan(x-MINVAL))/(1.0000000000000-(TANMIN*tan(x-MINVAL))));
}