Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: FastAtan2.h
- Revision:
- 1:9110a3da84c9
- Parent:
- 0:88345d07348b
- Child:
- 2:8bff2a7afea1
--- a/FastAtan2.h Tue Jun 14 17:02:30 2016 +0000 +++ b/FastAtan2.h Tue Jun 14 18:00:06 2016 +0000 @@ -1,27 +1,36 @@ /* - * MathFunc.h + * FastAtan2.h * * Created on: 22 de may. de 2016 * Author: Fede Pinna */ + #include "mbed.h" -#ifndef FASTATAN_H_ -#define FASTATAN_H_ +#ifndef FASTATAN2_H_ +#define FASTATAN2_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 + +/******************* Constant Q15 ********************/ + +#define PI_Q15 0x19220 // Pi +#define PI2_Q15 0xC910 // Pi/2 +#define PI4_Q15 0x6488 // Pi/4 +#define PIx2_Q15 0x32440 // 2*Pi +#define C1 0x1F52 // constante c1 = 0.2447 +#define C2 0x819 // constante c2 = 0.0663 + +/*************** Fixed-point operations ****************/ #define FSUBI(a,b,q) ((a)-((b)<<(q))) #define FMUL(a,b,q) (((a)*(b))>>(q)) +/************** Fixed-point conversions ****************/ + #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) @@ -29,4 +38,4 @@ int32_t atan2_q15(int32_t x,int32_t y); -#endif /* FASTATAN_H_ */ +#endif /* FASTATAN2_H_ */