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.
FastAtan2.h@1:9110a3da84c9, 2016-06-14 (annotated)
- Committer:
- Cotzo
- Date:
- Tue Jun 14 18:00:06 2016 +0000
- Revision:
- 1:9110a3da84c9
- Parent:
- 0:88345d07348b
- Child:
- 2:8bff2a7afea1
Comments added
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Cotzo | 0:88345d07348b | 1 | /* |
| Cotzo | 1:9110a3da84c9 | 2 | * FastAtan2.h |
| Cotzo | 0:88345d07348b | 3 | * |
| Cotzo | 0:88345d07348b | 4 | * Created on: 22 de may. de 2016 |
| Cotzo | 0:88345d07348b | 5 | * Author: Fede Pinna |
| Cotzo | 0:88345d07348b | 6 | */ |
| Cotzo | 1:9110a3da84c9 | 7 | |
| Cotzo | 0:88345d07348b | 8 | #include "mbed.h" |
| Cotzo | 0:88345d07348b | 9 | |
| Cotzo | 1:9110a3da84c9 | 10 | #ifndef FASTATAN2_H_ |
| Cotzo | 1:9110a3da84c9 | 11 | #define FASTATAN2_H_ |
| Cotzo | 0:88345d07348b | 12 | |
| Cotzo | 0:88345d07348b | 13 | #define QFORMAT 15 |
| Cotzo | 1:9110a3da84c9 | 14 | |
| Cotzo | 1:9110a3da84c9 | 15 | /******************* Constant Q15 ********************/ |
| Cotzo | 1:9110a3da84c9 | 16 | |
| Cotzo | 1:9110a3da84c9 | 17 | #define PI_Q15 0x19220 // Pi |
| Cotzo | 1:9110a3da84c9 | 18 | #define PI2_Q15 0xC910 // Pi/2 |
| Cotzo | 1:9110a3da84c9 | 19 | #define PI4_Q15 0x6488 // Pi/4 |
| Cotzo | 1:9110a3da84c9 | 20 | #define PIx2_Q15 0x32440 // 2*Pi |
| Cotzo | 1:9110a3da84c9 | 21 | #define C1 0x1F52 // constante c1 = 0.2447 |
| Cotzo | 1:9110a3da84c9 | 22 | #define C2 0x819 // constante c2 = 0.0663 |
| Cotzo | 1:9110a3da84c9 | 23 | |
| Cotzo | 1:9110a3da84c9 | 24 | /*************** Fixed-point operations ****************/ |
| Cotzo | 0:88345d07348b | 25 | |
| Cotzo | 0:88345d07348b | 26 | #define FSUBI(a,b,q) ((a)-((b)<<(q))) |
| Cotzo | 0:88345d07348b | 27 | #define FMUL(a,b,q) (((a)*(b))>>(q)) |
| Cotzo | 0:88345d07348b | 28 | |
| Cotzo | 1:9110a3da84c9 | 29 | /************** Fixed-point conversions ****************/ |
| Cotzo | 1:9110a3da84c9 | 30 | |
| Cotzo | 0:88345d07348b | 31 | #define TOFIX(d,q) ((int32_t)( (d)*(float)(1<<(q)) )) |
| Cotzo | 0:88345d07348b | 32 | #define TOFLT(a,q) ((float)(a)/(float)(1<<(q))) |
| Cotzo | 1:9110a3da84c9 | 33 | |
| Cotzo | 0:88345d07348b | 34 | #define RAD_Q15_TODEG(rad) ((rad*57)+0x25DC) |
| Cotzo | 0:88345d07348b | 35 | |
| Cotzo | 0:88345d07348b | 36 | |
| Cotzo | 0:88345d07348b | 37 | int32_t atan_q15(uint32_t x,uint32_t y); |
| Cotzo | 0:88345d07348b | 38 | int32_t atan2_q15(int32_t x,int32_t y); |
| Cotzo | 0:88345d07348b | 39 | |
| Cotzo | 0:88345d07348b | 40 | |
| Cotzo | 1:9110a3da84c9 | 41 | #endif /* FASTATAN2_H_ */ |