How to get the phone’s angle relative to the Earth’s magnetic field?

I planned to calculate the angle of the phone relative to the Earth’s magnetic field. For this, I planned to use Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR. The Geomagnetic Rotation Vector explains that event.valuesreturns the same value as in the Rotation the Vector , which,

  • x * sin (θ / 2),
  • y * sin (θ / 2),
  • z * sin (θ / 2),
  • owls (θ / 2)

What are the x, y, z values ​​in the above values? Using these values ​​Can I calculate the angles between the X axis of the phone and the X axis of the globe, the Y axis of the phone and the Y axis of the earth, and the Z axis of the phone and the Z axis of the earth?

PS: θ is described as the angle θ around the axis (x, y or z)

Phone's X, Y and Z axisEarth's X, Y and Z axis

+4
2

:

x - "" : 0 , -1, 1 . x .

y - "Yaw" : , y.

z - "Roll" : z.

-1 1, . Android Documentation , x, y, z (cos (θ/2), xsin (θ/2), ysin (θ/2), z * sin (θ/2)). , , , . http://3dgep.com/understanding-quaternions/

, , , // API Android. https://code.google.com/p/openintents/wiki/SensorSimulator

, Yaw 0, 0 , ( ), ​​ ( SensorSimulator , )

getRotationMatrix() SensorManager: Android doc

: https://android.googlesource.com/platform/development/+/master/samples/ApiDemos/src/com/example/android/apis/os/RotationVectorDemo.java

+1

, .

-3

All Articles