29 lines
364 B
C
29 lines
364 B
C
#include "maths.h"
|
|
|
|
#define MAX_TURN 6
|
|
|
|
float cos(float x)
|
|
{
|
|
unsigned int a = 8 * MAX_TURN - 6;
|
|
unsigned int b = 2 * MAX_TURN * (2 * MAX_TURN - 1); // 2n(2n-1)
|
|
float s = 1;
|
|
|
|
unsigned short 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);
|
|
}
|