Search code examples
androidorientationandroid-sensors

Finding a devices relative orientation in android


From what I understand, android uses world coordinates for the rotation matrix that I would use to get the orientation of the device. However I'm looking to get the devices orientation relative to the device itself similar to how attitude is represented in iOS.

In other words the axis used for roll would be a line passing through the top and bottom of the device, the pitch axis passing through the sides of the device and the yaw axis passing vertically through the device.

I would like to know if android provides any methods that would allow me to get these orientation values or if there is a way I'd be able to do this manually.

Any help would be greatly appreciated.


Solution

  • I eventually figured out a solution that suited my needs. I simply used the getAngleChange() method from the SensorManager class and used a calibration matrix as the previous matrix.