Android develops a method to obtain gravity acceleration and magnetic field strength
This paper describes the method of obtaining gravity acceleration and magnetic field strength developed by Android. Share with you for your reference, as follows:
Android mainly relies on:
input data:
Gravity is the gravity acceleration measured by the gravity sensor, float [3]; Geomagnetic is geomagnetic data measured by compass sensor float [3];
Output data:
R is the conversion matrix from the mobile phone device to the coordinate system to the real world coordinate system calculated by this method
I is the rotation matrix of the coordinates from the geomagnetic data to the gravity data
[0 g] = R * gravity [0 m 0] = I * r * geomagnetic (M = magnetic field strength)
The following is the result diagram I made
The core code is as follows:
More readers interested in Android related content can view the special topics of this site: introduction and advanced tutorial of Android development, summary of Android view skills, summary of activity operation skills of Android programming, summary of Android file operation skills, summary of Android resource operation skills and summary of Android control usage
I hope this article will help you in Android programming.