gba-trycatch
diff src/sincos.h @ 3:8e9225853d75
added sincos luts
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 14 Jun 2014 01:56:58 +0300 |
parents | |
children | 78d1664c2443 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/sincos.h Sat Jun 14 01:56:58 2014 +0300 1.3 @@ -0,0 +1,27 @@ 1.4 +#ifndef SINCOS_H_ 1.5 +#define SINCOS_H_ 1.6 + 1.7 +#include <stdint.h> 1.8 + 1.9 +#define M_PI_X16 (int32_t)(M_PI * 65536.0) 1.10 +/*#define M_PI_X16 (int32_t)((31416 << 16) / 10000)*/ 1.11 + 1.12 +#define SINLUT_SCALE 512 1.13 +#define SINLUT_SIZE 512 1.14 +int16_t sinlut[SINLUT_SIZE]; 1.15 + 1.16 +void sincos_init(void); 1.17 + 1.18 +/* takes angle in [0, SINLUT_SIZE] and returns: 1.19 + * sin(2 * angle / SINLUT_SIZE / pi) * SINLUT_SCALE 1.20 + */ 1.21 +int16_t sin_int(int16_t norm_angle); 1.22 +int16_t cos_int(int16_t norm_angle); 1.23 + 1.24 +/* takes angle in fixed point 16.16 radians [0, 2pi << 16] 1.25 + * and returns 16.16 fixed point in [-1 << 16, 1 << 16] 1.26 + */ 1.27 +int32_t sin_x16(int32_t radians); 1.28 +int32_t cos_x16(int32_t radians); 1.29 + 1.30 +#endif /* SINCOS_H_ */