xcode 加速度计移动的距离
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6645126/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Distance moved by Accelerometer
提问by MeIr
I want to move objects on iPhone screen (rectangle, circle and so on) by moving iPhone. For example, I move iPhone along X-axis and the object moves along X-axis. The same for Y,Z-axis.
我想通过移动 iPhone 来移动 iPhone 屏幕上的对象(矩形、圆形等)。例如,我沿 X 轴移动 iPhone,对象沿 X 轴移动。Y、Z 轴相同。
How can I do this? Can I get algorithm for it?
我怎样才能做到这一点?我可以得到它的算法吗?
Thank you.
谢谢你。
P.S: I looked for a while and seems like it is possible using accelerometer.
PS:我看了一会儿,似乎可以使用加速度计。
回答by Ali
You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice.
您可以通过对线性加速度进行两次积分来获得位置,但误差非常大。在实践中是没有用的。
Here is an explanation why (Google Tech Talk)at 23:20. I highly recommend this video.
这是23:20的解释(Google Tech Talk)。我强烈推荐这个视频。
However the gyro mousemight work for your application, see between 37:00-38:25 in the video.
但是,陀螺仪鼠标可能适用于您的应用程序,请参见视频中的 37:00-38:25。
Similar questions:
类似问题:
track small movements of iphone with no GPS
What is the real world accuracy of phone accelerometers when used for positioning?
how to calculate phone's movement in the vertical direction from rest?
iOS: Movement Precision in 3D Space
How to use Accelerometer to measure distance for Android Application Development
How can I find distance traveled with a gyroscope and accelerometer?
在没有 GPS 的情况下跟踪 iphone 的
小动作 当用于定位时,手机加速度计的真实世界精度是多少?
如何从静止计算手机在垂直方向上的运动?
iOS:3D 空间中的运动精度
如何使用加速度计测量 Android 应用程序开发的
距离如何找到陀螺仪和加速度计行进的距离?
回答by duskwuff -inactive-
Not easy to do accurately. An accelerometer only reports acceleration, not movement. You can try (numerically) integrating the acceleration over time, but you're likely to end up with cumulative errors adding up and leading to unintended motion.
不容易做到准确。加速度计只报告加速度,而不报告运动。您可以尝试(在数字上)随时间积分加速度,但最终可能会累积误差累积并导致意外运动。
Pseudocode, obviously untested:
伪代码,显然未经测试:
init:
loc = {0, 0, 0} ; location of object on screen
vel = {0, 0, 0} ; velocity of object on screen
t = 0 ; last time measured
step:
t0 = time ; get amount of time since last measurement
dt = t0 - t
accel = readAccelerometer()
vel += accel * dt ; update velocity
loc += vel * dt ; update position
displayObjectAt(loc)
回答by kubudi
Why don't you use the acceleration itself instead distance moved? For example; If your acceleration is 1.4G east, your object should move to east 14pixels per second until your acceleration changes.
为什么不使用加速度本身而不是移动的距离?例如; 如果您的加速度为 1.4G 向东,则您的对象应以每秒 14 个像素的速度向东移动,直到您的加速度发生变化。
So that object's movement is will be like it is under a relative force and I think it's more realistic. Faster moving device, bigger force to effect object.
所以那个物体的运动就像是在一个相对的力下,我认为它更真实。更快的移动装置,更大的力作用于物体。
Also look:
还看看:
http://www.freescale.com/files/sensors/doc/app_note/AN3397.pdf
http://www.freescale.com/files/sensors/doc/app_note/AN3397.pdf
and
和
Using accelerometer, gyroscope and compass to calculate device's movement in 3D world