aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui/CompassView.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 17:46:54 +0200
commit77448c73c305513df4f7651b3e56dbc59602ddc8 (patch)
treeffb4241bb23322e11c443ed9b91f6b93d28652d8 /main/src/cgeo/geocaching/ui/CompassView.java
parentaaa264d1748a9f399352e28f916ad579e4facf19 (diff)
downloadcgeo-77448c73c305513df4f7651b3e56dbc59602ddc8.zip
cgeo-77448c73c305513df4f7651b3e56dbc59602ddc8.tar.gz
cgeo-77448c73c305513df4f7651b3e56dbc59602ddc8.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/CompassView.java')
-rw-r--r--main/src/cgeo/geocaching/ui/CompassView.java10
1 files changed, 2 insertions, 8 deletions
diff --git a/main/src/cgeo/geocaching/ui/CompassView.java b/main/src/cgeo/geocaching/ui/CompassView.java
index 5401bfd..6f5b8b9 100644
--- a/main/src/cgeo/geocaching/ui/CompassView.java
+++ b/main/src/cgeo/geocaching/ui/CompassView.java
@@ -128,10 +128,7 @@ public class CompassView extends View {
* @return the new value
*/
static protected double smoothUpdate(double goal, double actual) {
- double diff = (goal - actual) % 360;
- if (diff < 0.0) {
- diff += 360.0;
- }
+ final double diff = (goal - actual + 360) % 360;
double offset = 0.0;
@@ -179,10 +176,7 @@ public class CompassView extends View {
}
double azimuthTemp = azimuthDrawn;
- double azimuthRelative = (azimuthTemp - headingDrawn) % 360;
- if (azimuthRelative < 0) {
- azimuthRelative += 360;
- }
+ final double azimuthRelative = (azimuthTemp - headingDrawn + 360) % 360;
// compass margins
int canvasCenterX = (compassRoseWidth / 2) + ((getWidth() - compassRoseWidth) / 2);