Measuring the exact angle of rotation of the device in android

I need to get the exact angle of my android device from each axis.

First I have to say that I was browsing the web pages as well as stackoverflow and I have seen pages like this:

How to measure the tilt angle of a phone in the XY plane with an accelerometer in Android

Get android rotation angle along x axis

But they didn't help. I've used some of them, but they give the wrong values.

If the axis in the device looks like this:

enter image description here

I need to get this rotation angle:

enter image description here

I don't want to use any hardware sensor other than the accelerometer and I am working with API 17 . I think it's possible based on racing games, but I don't know how to do it.

I would be grateful if you can help me. Thanks to

+3


source to share


1 answer


It is not possible to get all rotations with TYPE_ACCELEROMETER

. You also need TYPE_MAGNETIC_FIELD

. If you don't care how sensitive the values ​​are for fast travel, you need TYPE_GRAVITY

or TYPE_ACCELEROMETER

together with TYPE_MAGNETIC_FIELD

.
For z-axis rotation, you can follow the first link in your question.
For rotation in x and y axes, you can use pan and roll and screen.



0


source







All Articles