gba-x3dtest

view src/sincos.h @ 4:78d1664c2443

- fixed sin_x16/cos_x16 - added fixed point header
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Jun 2014 03:04:56 +0300
parents 8e9225853d75
children
line source
1 #ifndef SINCOS_H_
2 #define SINCOS_H_
4 #include <stdint.h>
6 /*#define M_PI_X16 (int32_t)(M_PI * 65536.0) */
7 #define M_PI_X16 (int32_t)((31416 << 16) / 10000)
9 #define SINLUT_SCALE 512
10 #define SINLUT_SIZE 512
11 int16_t sinlut[SINLUT_SIZE];
13 void sincos_init(void);
15 /* takes angle in [0, SINLUT_SIZE] and returns:
16 * sin(2 * angle / SINLUT_SIZE / pi) * SINLUT_SCALE
17 */
18 int16_t sin_int(int16_t norm_angle);
19 int16_t cos_int(int16_t norm_angle);
21 /* takes angle in fixed point 16.16 radians [0, 2pi << 16]
22 * and returns 16.16 fixed point in [-1 << 16, 1 << 16]
23 */
24 int32_t sin_x16(int32_t radians);
25 int32_t cos_x16(int32_t radians);
27 #endif /* SINCOS_H_ */