Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'platform/location.hpp')
-rw-r--r--platform/location.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/platform/location.hpp b/platform/location.hpp
index 978bf8aeab..576c95a3ee 100644
--- a/platform/location.hpp
+++ b/platform/location.hpp
@@ -5,6 +5,7 @@
#include "../routing/turns.hpp"
#include "../std/string.hpp"
+#include "../std/cmath.hpp"
namespace location
@@ -73,6 +74,22 @@ namespace location
return lon != 0. && lon < 180. && lon > -180.;
}
+
+ // Convert angle (in degrees counterclockwise from X) to bearing ([0, 360) clockwise from the north)
+ static inline double AngleToBearing(double a)
+ {
+ double reverseAng = fmod(-a + 90, 360.);
+ if (reverseAng < 0)
+ reverseAng += 360.;
+ return reverseAng;
+ }
+
+ // Convert bearing (in degrees clockwise from the north) to angle ([0, 360) counterclockwise from X)
+ static inline double BearingToAngle(double a)
+ {
+ return AngleToBearing(a);
+ }
+
class FollowingInfo
{
public: