Reputation: 61
I want to get the rotation on x, y and z axis
I want to get these values
Upvotes: 1
Views: 74
Reputation: 430
You can obtain Azimuth, Pitch and Roll in this way:
private SensorManager sensorManager;
...
// Rotation matrix based on current readings from accelerometer and magnetometer.
final float[] rotationMatrix = new float[9];
SensorManager.getRotationMatrix(rotationMatrix, null,
accelerometerReading, magnetometerReading);
// Express the updated rotation matrix as three orientation angles.
final float[] orientationAngles = new float[3];
SensorManager.getOrientation(rotationMatrix, orientationAngles);
source https://developer.android.com/guide/topics/sensors/sensors_position#java
Upvotes: 1