简体   繁体   中英

How to calculate g-force using x, y, z values from the accelerometer in Android 1.6

I can get the three x, y, and z values from the accelerometer in Android. How can I use these to calculate the g-force?

If the accelerometer measures acceleration in meters per second squared (the SI unit), you can convert each acceleration into a g-force measurement by dividing by 9.81 .

If you want the g-force as an directionless measurement, you just need to apply the pythagorean theorem to the different components of the acceleration:

double g = Math.sqrt(x * x + y * y + z * z);

Just select TYPE_GRAVITY instead of TYPE_ACCELEROMETER as sensor type:

https://developer.android.com/guide/topics/sensors/sensors_motion.html#sensors-motion-grav

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM