Trigonomectric constants Polar and spherical to rectangular coordinates transform
Dependents: DISCO-F746NG_Lidar ZAILLEL_Interface
Diff: Trigo.cpp
- Revision:
- 0:2f533ad7c611
- Child:
- 1:eb028056d162
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Trigo.cpp Sun Nov 25 11:13:56 2012 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" +#include "Trigo.h" + +void RecPol(float x, float y, float *r, float *a) +{*r=sqrt(x*x+y*y); +if (x==0.0) + {if (y==0.0) + {*a=0.0;} + else + {if (y>=0.0) + {*a=Pis2;} + else + {*a=-Pis2;}}} +else + {*a=atan(y/x); + if(x<0) + {*a=Pi+*a;} + if (*a>Pi) + {*a=*a-DeuxPi;} + } +} + +void PolRec(float r, float a, float *x, float *y) +{*x=r*cos(a); + *y=r*sin(a); +} + +void RecSph(float x, float y, float z, float *r, float *a, float *b) +{RecPol(x,y,b,a); + RecPol(*b,z,r,b); +} + +void SphRec(float r, float a, float b, float *x, float *y, float *z) +{PolRec(r,b,x,z); + PolRec(*x,a,x,y); +} \ No newline at end of file