Guillaume Chauvon
/
Asserve12
asser1
Diff: math_precalc.cpp
- Revision:
- 1:0690cf83f060
- Parent:
- 0:6ca63d45f0ee
- Child:
- 2:5764f89a27f6
--- a/math_precalc.cpp Tue Dec 11 19:12:55 2018 +0000 +++ b/math_precalc.cpp Wed Dec 12 20:03:07 2018 +0000 @@ -28,6 +28,52 @@ } double pow(long int a, long int b) -{ +{ return pow((double) a, (double) b); -} \ No newline at end of file +} + +double abs(double a) +{ + if (a<0) {return -a;} + return a; +} + +double diff_angle(double angle1, double angle2) +{ + // en degré + if (abs(angle2 - angle1) <= 180) + { + return angle2-angle1; + } + else if (angle2-angle1>0) + { + return (angle2-angle1)-360; + } + else + { + return 360+(angle2-angle1); + } +} + +double borne_angle_r(double angle) +{ + if (angle > PI) { + angle -= 2*PI; + } + else if (angle <= -PI) { + angle += 2*PI; + } + return angle; +} + +double borne_angle_d(double angle) +{ + if (angle > 180) { + angle -= 2*180; + } + else if (angle <= -180) { + angle += 2*180; + } + return angle; +} +