diff options
Diffstat (limited to 'main/src/cgeo/geocaching/DirectionProvider.java')
| -rw-r--r-- | main/src/cgeo/geocaching/DirectionProvider.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/DirectionProvider.java b/main/src/cgeo/geocaching/DirectionProvider.java index 7bb940f..2f54b41 100644 --- a/main/src/cgeo/geocaching/DirectionProvider.java +++ b/main/src/cgeo/geocaching/DirectionProvider.java @@ -60,4 +60,15 @@ public class DirectionProvider extends MemorySubject<Float> implements SensorEve return Compatibility.getDirectionNow(direction, activity) % 360; } + /** + * Return the angle to turn of to go from an angle to the other + * + * @param from the origin angle in degrees, in the [0, 360[ range + * @param to the target angle in degreees, in the [0, 360[ range + * @return a value in degrees, in the [-180, 180[ range + */ + public static double difference(final double from, final double to) { + return (to - from + 360 + 180) % 360 - 180; + } + } |
