iOS CoreMotion - 计算高度差异 [英] iOS CoreMotion - Calculating Height Difference
问题描述
当iPhone使用CoreMotion的数据移动时,是否可以计算高度差?
Is it possible to calculate the difference in height when an iPhone moves using the data from CoreMotion?
例如,保存iPhone的初始位置,然后移动iPhone会产生新的位置。我有兴趣检测iPhone的高度是否从其初始位置移开。我不需要绝对单位,只需要一个相对值来表示高度从原始高度变化的百分比。
For example, the initial position of the iPhone is saved, then the iPhone is moved which results in a new position. I am interested in detecting if the height of the iPhone moved from its initial position. I don't need absolute units, just a relative value indicating what percentage the height has changed from its original height.
let manager = CMMotionManager()
// Save initial attitude
var initialAttitude = manager.deviceMotion.attitude
if manager.deviceMotionAvailable {
manager.startDeviceMotionUpdatesToQueue(NSOperationQueue.mainQueue()) {
[weak self] (data: CMDeviceMotion!, error: NSError!) in
// Get the difference between the initial and new attitude
data.attitude.multiplyByInverseOfAttitude(initialAttitude)
// Is there a way to calculate the relative change in height?
}
}
推荐答案
不,这是不可能的。抱歉。
No, this isn't possible. Sorry.
有一篇很好的论文解释了为什么这是不可能的,但我现在找不到它。如果我发现它,我会发布一个链接。
There is a nice paper explaining why this isn't possible but I' can't find it at the moment. If I find it I'll post a link.
但是,通过使用加速度计等来测量移动的距离...是不可能的,主要是因为噪音通过双重整合大大增加。
But yeah, measuring distance moved by just using the accelerometer etc... isn't possible due mainly to noise that is vastly increased by double integration.
另外,我认为你很困惑态度
和海拔高度
。
Also, I think you're confusing Attitude
and Altitude
.
前者是描述方向的对象使用滚动,俯仰,偏航等设备...... CMDeviceMotion
的态度
属性。
The former is an object describing the orientation of the device using roll, pitch, yaw, etc... The attitude
property of the CMDeviceMotion
.
后者是海拔高度,不能通过iOS获得。您可以在iOS中获得的唯一海拔高度
是地球上特定点高于海平面的高度。但你无法获得设备的高度,只能获得地面的高度。
The latter is the height above sea level and isn't available through iOS. The only altitude
you can get in iOS is the height a particular point on the earth is above sea-level. But you can't get the device altitude, just the ground's altitude.
无论哪种方式,它仍然无法实现。
Either way, it's still not possible.
这不是一篇论文。这是一段视频。
It wasn't a paper. It was a video.
https:/ /www.youtube.com/watch?v=_q_8d0E3tDk
这篇关于iOS CoreMotion - 计算高度差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!