FastMath reorganization

This commit is contained in:
Emux
2018-02-11 11:19:54 +02:00
parent bd9e7d7456
commit 67dde0af7d
9 changed files with 86 additions and 98 deletions

View File

@@ -32,6 +32,7 @@ import org.oscim.event.Event;
import org.oscim.layers.Layer;
import org.oscim.map.Map;
import org.oscim.renderer.LocationRenderer;
import org.oscim.utils.FastMath;
@SuppressWarnings("deprecation")
public class Compass extends Layer implements SensorEventListener, Map.UpdateListener,
@@ -230,20 +231,13 @@ public class Compass extends Layer implements SensorEventListener, Map.UpdateLis
// float rotation = (float) Math.toDegrees(mAzimuthRadians);
float change = rotation - mCurRotation;
if (change > 180)
change -= 360;
else if (change < -180)
change += 360;
change = (float) FastMath.clampDegree(change);
// low-pass
change *= 0.05;
rotation = mCurRotation + change;
if (rotation > 180)
rotation -= 360;
else if (rotation < -180)
rotation += 360;
rotation = (float) FastMath.clampDegree(rotation);
// float tilt = (float) Math.toDegrees(mRotationV[1]);
// float tilt = (float) Math.toDegrees(mPitchAxisRadians);