29 lines
334 B
C
29 lines
334 B
C
#include "maths.h"
|
|
|
|
#define MAX_TURN 24
|
|
|
|
float cos(float x)
|
|
{
|
|
int a = 8 * MAX_TURN - 6;
|
|
int b = 2 * MAX_TURN * (2 * MAX_TURN - 1); // 2n(2n-1)
|
|
float s = 1;
|
|
|
|
int i;
|
|
|
|
x = x*x; // x²
|
|
|
|
for(i = 0; i < MAX_TURN; i++)
|
|
{
|
|
s = 1 - x * s / b;
|
|
b -= a;
|
|
a -= 8;
|
|
}
|
|
|
|
return s;
|
|
}
|
|
|
|
float sin(float x)
|
|
{
|
|
return cos(x - pi_2);
|
|
}
|