thanks everybody, here the solution I'm using:
BigNumber sine (BigNumber x, BigNumber p)
{
while (x > doublePI){//stay in range!
x -= doublePI;
}
while (x < 0){//stay in range!
x += doublePI;
}
BigNumber one = 1;
BigNumber two = 2;
BigNumber val = one;
while (p > 0)
{
val = one - val * x * x / (two * p) / (two * p + one);
p = p - one;
}
val = x * val;
return val;
} // end of sine
BigNumber cosine (BigNumber x, BigNumber p)
{
return sine(x+halfPI, p);
} // end of cosine
BigNumber tangent (BigNumber x, BigNumber p)
{
return (sine (x, p) / sine (x+halfPI, p));
} // end of tangent
note you will need halfPI and doublePI:
BigNumber::begin ();
BigNumber::setScale (20);
bigPI = BigNumber ("3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706");
halfPI = bigPI;
halfPI /= 2;
doublePI = bigPI;
doublePI *= 2;
now i'm going to test the real duration of my code at different precision, i'll post here the code and the results. thanks again everybody!!!
edit: it's a honour to talk with the man who wrote this lib. just a little problem (arduino IDE 1.0.1):
halfPI = PI / 2;
give some error with overloaded constructor. I've work around it because I'm not good with c++ ![]()