Federico Luis Pinna Gonzalez / FastAtan2

Dependents:   FastECompass

Revision:
0:88345d07348b
Child:
1:9110a3da84c9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FastAtan2.h	Tue Jun 14 17:02:30 2016 +0000
@@ -0,0 +1,32 @@
+/*
+ * MathFunc.h
+ *
+ *  Created on: 22 de may. de 2016
+ *      Author: Fede Pinna
+ */
+#include "mbed.h"
+
+#ifndef FASTATAN_H_
+#define FASTATAN_H_
+
+#define QFORMAT 15
+#define PI_Q15 0x19220 // Pi fp16
+#define PI2_Q15 0xC910 // Pi/2 fp16
+#define PI4_Q15 0x6488// Pi/4 fp16
+#define PIx2_Q15 0x32440
+#define C1 0x1F52 // constante c1 = 0.2447
+#define C2 0x819 //	constante c2 = 0.0663
+
+#define FSUBI(a,b,q) ((a)-((b)<<(q)))
+#define FMUL(a,b,q) (((a)*(b))>>(q))
+
+#define TOFIX(d,q) ((int32_t)( (d)*(float)(1<<(q)) ))
+#define TOFLT(a,q) ((float)(a)/(float)(1<<(q)))
+#define RAD_Q15_TODEG(rad) ((rad*57)+0x25DC)
+
+
+int32_t atan_q15(uint32_t x,uint32_t y);
+int32_t atan2_q15(int32_t x,int32_t y);
+
+
+#endif /* FASTATAN_H_ */