Package com.gluonhq.attach.magnetometer
Class MagnetometerReading
java.lang.Object
com.gluonhq.attach.magnetometer.MagnetometerReading
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
ConstructorDescriptionMagnetometerReading
(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 TypeMethodDescriptiondouble
Azimuth (rotation about the -z axis, degrees).double
Returns the magnitude of the reading, microtesla unitsdouble
getPitch()
Pitch (rotation about the x axis, radians).double
getRoll()
Roll (rotation about the y axis, radians).double
getX()
Returns the x value of the reading, microtesla units.double
getY()
Returns the y value of the reading, microtesla unitsdouble
getYaw()
Yaw (rotation about the -z axis, radians).double
getZ()
Returns the z value of the reading, microtesla units
-
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 readingy
- The y value of the readingz
- The z value of the readingmagnitude
- The magnitude of the readingyaw
- rotation about the -z axispitch
- rotation about the x axisroll
- 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.
-