TYPE_ACCELEROMETER和TYPE_LINEAR_ACCELERATION传感器有什么区别? [英] What is the difference between TYPE_ACCELEROMETER and TYPE_LINEAR_ACCELERATION sensors?

查看:392
本文介绍了TYPE_ACCELEROMETER和TYPE_LINEAR_ACCELERATION传感器有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为TYPE_ACCELEROMETER显示设备加速.但是,我不知道何时应该使用TYPE_LINEAR_ACCELERATION?
我需要计算移动设备的速度.哪种传感器适合该应用?

I think TYPE_ACCELEROMETER shows devices acceleration. However, I can't understand when I should use TYPE_LINEAR_ACCELERATION?
I need to calculate the speed of moving the device. Which sensor is proper for this application?

此外,我读到TYPE_LINEAR_ACCELERATION使用加速度计和方向来了解重力的方向,然后俯冲.

Also, I read that TYPE_LINEAR_ACCELERATION uses accelerometer and orientation to know where is directed the gravity and then subs.

这怎么可能? Android如何找出设备的方向并将其减去?

How is this possible? How Android find out about orientation of device and subtract it?

推荐答案

根据

According to http://developer.android.com/reference/android/hardware/SensorEvent.html#values TYPE_LINEAR_ACCELERATION is the same as TYPE_ACCELEROMETER minus gravity: acceleration = gravity + linear-acceleration. So with TYPE_LINEAR_ACCELERATION you can't detect device orientation because it doesn't provide gravity data.

加速度是对象位置的第二阶导数,速度( velocity )是一阶导数.这意味着您可以根据加速度计算出速度的相对变化,但通常情况下您无法从中知道变化所应用的精确速度值.例如,您不能说电话是放在房间的桌子上还是在不断行驶的汽车中,两种情况下加速度都可能为零.

Acceleration is the second derivative from object location, speed (velocity) is the first derivative. It means that you can calculate relative change in velocity from acceleration, but you can't know from it what exact values of velocity the change is applied to, in general case. For example you can't say if the phone stands on a table in room or in a constantly moving car, in both cases the acceleration may be zero.

游戏使用加速度计输入来跟踪用户的反馈,因为对于游戏来说,如果用户坐在移动的汽车或餐桌旁,这都无关紧要,那么加速度恰好符合此目的(过滤出速度数据).如果您确实需要速度,则应该使用其他传感器,例如 GPS .

Games use accelerometer input to track user's feedback, since it doesn't matter for games if user sits in a moving car or home at a table, acceleration just fits that purpose perfectly (filtering out the speed data). If you really need speed then you should use other sensors, such as GPS.

一个安全的假设是,手机最初与用户具有相同的速度,因此您可以计算出用户扔掉手机时相对于用户的速度,仅此而已.

It may be a safe assumption that the phone initially has the same speed as the user, so you can calculate speed of phone when user throws it away, relative to the user, but that's all.

这篇关于TYPE_ACCELEROMETER和TYPE_LINEAR_ACCELERATION传感器有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆