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

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

+3
source share
2 answers

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

If you want the g-force to be measured without indicating direction, you just need to apply the pythagorean theorem to the various acceleration components:

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

Just choose TYPE_GRAVITYinstead TYPE_ACCELEROMETERas the type of sensor:

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

0

All Articles