我正在尝试复制应用程序“Dynolicious”之类的加速度计算,但我不知道该去哪里进行计算。我是使用 Core Motion
还是使用其他数字进行计算?
我曾尝试使用 Core Motion
的 userAcceleraion
值,但结果完全不像我想要的那样。
coreMotion = [[CMMotionManager alloc]init];
[coreMotion startDeviceMotionUpdates];
//then every second it updates my label...
NSString *accel = [NSString stringWithFormat"%f", [[coreMotion accelerometerData]acceleration].x];
accelerationLabel.text = accel;
即我希望我的值像 0.4、-0.4 等一样。
您可能需要考虑低通滤波(显示在 this SO post 中),这实际上是 Apple 的指南(参见事件处理编程指南的 Isolating the Gravity Component from Acceleration Data)
If you are using the accelerometer data to detect the current orientation of a device, you need to be able to filter out the portion of the acceleration data caused by gravity from the portion of the data that is caused by motion of the device. To do this, you can use a low-pass filter to reduce the influence of sudden changes on the accelerometer data. The resulting filtered values then reflect the more constant effects of gravity.
您还可以查看“从加速度数据中分离瞬时运动”部分
If you are using accelerometer data to detect just the instant motion of a device, you need to be able to isolate sudden changes in movement from the constant effect of gravity. You can do that with a high-pass filter.
它接着给出了一个简单的实现来完成这个。
关于iphone - 计算加速度(驾驶汽车),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8157731/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |