half-assed 3D graphics attempt underway
[regis] / sincos.h
diff --git a/sincos.h b/sincos.h
new file mode 100644 (file)
index 0000000..82d7c5e
--- /dev/null
+++ b/sincos.h
@@ -0,0 +1,27 @@
+#ifndef SINCOS_H_
+#define SINCOS_H_
+
+#include <stdint.h>
+
+/*#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_ */