Class MagnetometerReading

java.lang.Object
com.gluonhq.attach.magnetometer.MagnetometerReading

public final class MagnetometerReading extends Object
Represents a reading taken from the MagnetometerService. By using a device's geomagnetic field sensor in combination with the device's accelerometer, three orientation angles (azimut, pitch and roll) can be determined
Since:
3.0.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    MagnetometerReading(double x, double y, double z, double magnitude, double yaw, double pitch, double roll)
    Creates a new immutable Reading instance with the given x, y, z, magnitude values, and orientation angles.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Azimuth (rotation about the -z axis, degrees).
    double
    Returns the magnitude of the reading, microtesla units
    double
    Pitch (rotation about the x axis, radians).
    double
    Roll (rotation about the y axis, radians).
    double
    Returns the x value of the reading, microtesla units.
    double
    Returns the y value of the reading, microtesla units
    double
    Yaw (rotation about the -z axis, radians).
    double
    Returns the z value of the reading, microtesla units

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MagnetometerReading

      public MagnetometerReading(double x, double y, double z, double magnitude, double yaw, double pitch, double roll)
      Creates a new immutable Reading instance with the given x, y, z, magnitude values, and orientation angles.
      Parameters:
      x - The x value of the reading
      y - The y value of the reading
      z - The z value of the reading
      magnitude - The magnitude of the reading
      yaw - rotation about the -z axis
      pitch - rotation about the x axis
      roll - rotation about the y axis
  • Method Details

    • getX

      public double getX()
      Returns the x value of the reading, microtesla units.
      Returns:
      The x value of the reading.
    • getY

      public double getY()
      Returns the y value of the reading, microtesla units
      Returns:
      The y value of the reading.
    • getZ

      public double getZ()
      Returns the z value of the reading, microtesla units
      Returns:
      The z value of the reading.
    • getMagnitude

      public double getMagnitude()
      Returns the magnitude of the reading, microtesla units
      Returns:
      The magnitude of the reading.
    • getYaw

      public double getYaw()
      Yaw (rotation about the -z axis, radians). This is the angle between the device's current compass direction and the magnetic north. Top edge of the device faces magnetic N: 0 degrees, S: Pi, E: Pi/2, W: -Pi/2. The range of values is -Pi to Pi.
      Returns:
      yaw angle
    • getPitch

      public double getPitch()
      Pitch (rotation about the x axis, radians). This is the angle between a plane parallel to the device's screen and a plane parallel to the ground. Tilting the top edge of the device toward the ground: the pitch angle becomes positive. Tilting the top edge of the device away from the ground: the pitch angle to become negative. The range of values is -Pi to Pi.
      Returns:
      pitch angle
    • getRoll

      public double getRoll()
      Roll (rotation about the y axis, radians). This is the angle between a plane perpendicular to the device's screen and a plane perpendicular to the ground. Tilting to the left the device toward the ground, the roll angle becomes positive. Tilting to the right the device toward the ground, the roll angle to become negative. The range of values is -Pi to Pi.
      Returns:
      roll angle
    • getAzimuth

      public double getAzimuth()
      Azimuth (rotation about the -z axis, degrees). Returns the compass reading, represented as a value between 0 and 359.99, where 0 is the magentic north.
      Returns:
      The current compass reading in degrees.