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.
Dependencies: mbed X_NUCLEO_IHM02A1
Diff: math_precalc.cpp
- Revision:
- 1:0690cf83f060
- Parent:
- 0:6ca63d45f0ee
--- 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;
+}
+