aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui/CompassMiniView.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2012-05-31 13:45:16 +0200
committerSamuel Tardieu <sam@rfc1149.net>2012-05-31 13:51:06 +0200
commitb3114d061ee3053bb9f1c200aabcc6387a9dfb35 (patch)
tree2e6ead415297a6eae38acf61b717718d9d35c949 /main/src/cgeo/geocaching/ui/CompassMiniView.java
parentf86b01359732af09a04d1379785e031cb8cc480b (diff)
downloadcgeo-b3114d061ee3053bb9f1c200aabcc6387a9dfb35.zip
cgeo-b3114d061ee3053bb9f1c200aabcc6387a9dfb35.tar.gz
cgeo-b3114d061ee3053bb9f1c200aabcc6387a9dfb35.tar.bz2
Simplify previous fix due to root cause fixing
The fix for #1680 introduced in ad93745d42f9aaf5bc4925075987ef64c13b2f71 had to account for the possibility of angles being outside the [0, 360[ range. Commit 0034e358668d5911639628468be7409b2696d6c5 fixed #1685 and now ensures that the returned orientation is within the right domain range even after the phone rotation has been added to the sensor angle. It is now possible to simplify the computation because we now that the difference of two angle values will always be in the ]-360; 720[ range, and can this fixed by adding 360 and taking the module with 360 to enter back the [0, 360[ range.
Diffstat (limited to 'main/src/cgeo/geocaching/ui/CompassMiniView.java')
-rw-r--r--main/src/cgeo/geocaching/ui/CompassMiniView.java6
1 files changed, 1 insertions, 5 deletions
diff --git a/main/src/cgeo/geocaching/ui/CompassMiniView.java b/main/src/cgeo/geocaching/ui/CompassMiniView.java
index 8c7c52e..1c96a09 100644
--- a/main/src/cgeo/geocaching/ui/CompassMiniView.java
+++ b/main/src/cgeo/geocaching/ui/CompassMiniView.java
@@ -159,11 +159,7 @@ final public class CompassMiniView extends View {
}
private float calculateAzimuthRelative() {
- float azimuthRelative = (azimuth - heading) % 360;
- if (azimuthRelative < 0) {
- azimuthRelative += 360;
- }
- return azimuthRelative;
+ return (azimuth - heading + 360) % 360;
}
@Override