Answers for "magnetic declination android studio"

0

magnetic declination android studio

public void setLocation(Location location)
  {
    GeomagneticField geomagneticField = new GeomagneticField(
      (float) location.getLatitude(),
      (float) location.getLongitude(),
      (float) location.getAltitude(),
      System.currentTimeMillis());
    declination = (float) Math.toRadians(geomagneticField.getDeclination());
  }
}
Posted by: Guest on July-09-2020
0

magnetic declination android studio

private void updateSensorValues(SensorEvent event) {
  if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
    setAcclValues(event);
  } else if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
    setmagValues(event);
  }
  SensorManager.getRotationMatrix(rotation, null, grav, mag);
  SensorManager.getOrientation(rotation, orientation);
  double floatBearing = orientation[0];
  floatBearing = Math.toDegrees(floatBearing); 
  if (magField != null)
    floatBearing += magField.getDeclination();
  if (floatBearing < 0)
    floatBearing += 360;
  setBearing(floatBearing);
  setRotationInDegrees(floatBearing);
}
Posted by: Guest on July-09-2020

Browse Popular Code Answers by Language