菜鸟教程小白 发表于 2022-12-13 09:08:56

IOS加速度计/陀螺仪问题


                                            <p><p>我想编写一个应用程序,从某个坐标(手机底部)给出位置度数。 </p>

<p>例如...如果我以 45 度角拿着手机,我想在屏幕上显示:45 度。如果用户将手机保持在 45 度角并围绕从听筒到主页按钮的轴旋转手机,我想显示该角度(0-180 度之间)。 </p>

<p>我已经实现了加速度计并获得了 x、y、z 值,但是,如何转换它们?我知道它们在 G 中(相应轴上为 1G、0.9G、-0.5G),但转换是什么?我什至走在正确的轨道上吗?我应该改用陀螺仪吗?</p>

<p>谢谢。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p> <a href="https://stackoverflow.com/questions/10262586/get-device-plane-relative-to-ground-plane-using-accelerometer" rel="noreferrer noopener nofollow">This question</a>有一个例子。您可以使用 <code>atan2(y, x)</code> 并使用 <code>* (180/M_PI)</code> 将弧度转换为度数。</p>

<blockquote>
<p>For any real arguments x and y not both equal to zero, atan2(y, x) is the angle in radians between the positive x-axis of a plane and the point given by the coordinates (x, y) on it.</p>
</blockquote>

<p>- 维基百科关于 <a href="http://en.wikipedia.org/wiki/Atan2" rel="noreferrer noopener nofollow">atan2</a> 的文章</p></p>
                                   
                                                <p style="font-size: 20px;">关于IOS加速度计/陀螺仪问题,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/7522436/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/7522436/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: IOS加速度计/陀螺仪问题