For some applications where you need to calculate many sines and cosines per second (games, etc) is very difficult to calculate. So today I bring an approach quadratic midterm. The function is:
y = -0.405282839 * (x) * (x-3.1416)
This speeds up a lot of our applications using trigonometric operations. The problem is you have to remember to treat the negative angle> PI.
code in c + + adaptable to other languages:
double sin (double rad) {
if (rad <0) return -sin(-rad);
if (rad> 2 * 3.1416) return sin (rad% 2 * 3.1416);
if (rad> 3.1416) return - (-0.405282839 * rad * (rad-3.1416)) return
-0.405282839 * rad * (rad-3.1416)}
0 comments:
Post a Comment