X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=regis;a=blobdiff_plain;f=sincos.h;fp=sincos.h;h=82d7c5e1f58fa78b4627e4c620c2a61524603515;hp=0000000000000000000000000000000000000000;hb=4ac276ea513d4460f9db8c43b4dbde5ebad652b5;hpb=46aa499cb189f9eb533e1e5a95a3770a0b3df8b4 diff --git a/sincos.h b/sincos.h new file mode 100644 index 0000000..82d7c5e --- /dev/null +++ b/sincos.h @@ -0,0 +1,27 @@ +#ifndef SINCOS_H_ +#define SINCOS_H_ + +#include + +/*#define M_PI_X16 (int32_t)(M_PI * 65536.0) */ +#define M_PI_X16 (int32_t)((31416 << 16) / 10000) + +#define SINLUT_SCALE 512 +#define SINLUT_SIZE 512 +int16_t sinlut[SINLUT_SIZE]; + +void sincos_init(void); + +/* takes angle in [0, SINLUT_SIZE] and returns: + * sin(2 * angle / SINLUT_SIZE / pi) * SINLUT_SCALE + */ +int16_t sin_int(int16_t norm_angle); +int16_t cos_int(int16_t norm_angle); + +/* takes angle in fixed point 16.16 radians [0, 2pi << 16] + * and returns 16.16 fixed point in [-1 << 16, 1 << 16] + */ +int32_t sin_x16(int32_t radians); +int32_t cos_x16(int32_t radians); + +#endif /* SINCOS_H_ */