简体   繁体   English

如何使用 Android 1.6 中加速度计的 x、y、z 值计算 g 力

[英]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.我可以从 Android 中的加速度计获得三个 x、y 和 z 值。 How can I use these to calculate the g-force?我如何使用这些来计算 g 力?

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 .如果加速度计以米每秒平方(SI 单位)为单位测量加速度,您可以通过除以9.81将每个加速度转换为g 力测量值。

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:如果要将 g 力作为无方向测量,只需将勾股定理应用于加速度的不同分量:

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

Just select TYPE_GRAVITY instead of TYPE_ACCELEROMETER as sensor type:只需 select TYPE_GRAVITY而不是TYPE_ACCELEROMETER作为传感器类型:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Phonegap中的加速度计xyz值计算位置 - How to calculate position from accelerometer x y z values in phonegap 在Android中每秒从加速度计获得峰值g力的最佳方法? - Best way to get peak g-force from accelerometer every second in Android? 从Android中的加速度计获得的x,y,z值是什么? - What does x,y,z values obtained from accelerometer in Android indicate? 如何在不具有android中更新值的情况下仅获取加速度计X,Y,Z值? - How do I get just the accelerometer X, Y, Z values without having an updating value in android? 使用加速度计读取android手机的xyz坐标 - Read x y z coordinates of android phone using accelerometer 如何以固定频率(例如,每20ms,40 ms或60 ms)从Android加速度传感器获取x,y,z值 - How to get x, y, z values from Android Accelerometer sensor on a regular frequency, for instance per 20ms, 40 ms or 60 ms 排除在Android应用中使用计算g力进行摇动 - Rule out shaking with calculating g-force in android app 如何在Android中使用重力或加速度传感器计算离心力 - How to calculate centrifugal force with gravity or accelerometer sensor in android 在不访问事件的情况下获取android中的加速度计信息(xyz坐标) - Get accelerometer information (x y z coordinates) in android without access to events Android:如何从(x,y)坐标计算图像的纬度和经度? - Android:How to calculate latitude and longitude of an image from (x,y) coordinates?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM