菜鸟教程小白 发表于 2022-12-13 09:46:45

iphone - 计算加速度(驾驶汽车)


                                            <p><p>我正在尝试复制应用程序“Dynolicious”之类的加速度计算,但我不知道该去哪里进行计算。我是使用 <code>Core Motion</code> 还是使用其他数字进行计算? </p>

<p>我曾尝试使用 <code>Core Motion</code> 的 <code>userAcceleraion</code> 值,但结果完全不像我想要的那样。</p>

<pre><code>coreMotion = [init];
;

//then every second it updates my label...

NSString *accel = acceleration].x];
accelerationLabel.text = accel;
</code></pre>

<p>即我希望我的值像 0.4、-0.4 等一样。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您可能需要考虑低通滤波(显示在 <a href="https://stackoverflow.com/questions/1211589/uiacceleration-filtering" rel="noreferrer noopener nofollow">this SO post</a> 中),这实际上是 Apple 的指南(参见事件处理编程指南的 <a href="http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MotionEvents/MotionEvents.html" rel="noreferrer noopener nofollow">Isolating the Gravity Component from Acceleration Data</a>)</p>

<blockquote>
<p>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.</p>
</blockquote>

<p>您还可以查看“从加速度数据中分离瞬时运动”部分</p>

<blockquote>
<p>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.</p>
</blockquote>

<p>它接着给出了一个简单的实现来完成这个。</p></p>
                                   
                                                <p style="font-size: 20px;">关于iphone - 计算加速度(驾驶汽车),我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/8157731/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/8157731/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iphone - 计算加速度(驾驶汽车)