使用方向信息来获取向下方向
我正在开发一个应用程序,该应用程序涉及根据其方向在我的 Android 屏幕上画一条线,并且可以使用一些帮助或指针。
这条线的绘制方式如下:如果手机平放,那么这条线会收缩并变成一个点,而当手机倾斜和定向时,这条线会变大 - 即手机直立,线指向下方,并且最大星等为 9.8,平放时它是一个小点。至关重要的是,无论手机以什么角度握持,箭头始终指向下方,即重力线。
现在我弄清楚了如何计算手机的偏航俯仰角和滚动角,但从数学上讲,我对如何从这些信息中推导出这条线的向量有点迷失——任何指针都会受到欢迎。
谢谢
I am working on an app that involves drawing a line on my android screen based on its orientation and could use some help or pointers.
The line is drawn in the following way: If the phone is held flat then then the line shrinks and becomes a dot and as the phone is tilted and orientatated the line becomes bigger - ie the phone stood up and the line points down and is max magnitude of 9.8 and held flat it is a small dot. Crucialy no matter what angle the phone is held at the arrow allways points down- ie the line of gravity.
Now I figured out how to calculate the yaw pitch and roll angles of the phones but mathematically I am a bit lost on how to derive the vector of this line from this information - any pointers would be most welcome.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我在 Replica Island 来源和 Nvidia 论文的帮助下解决了这个问题。
从 TYPE_ORIENTATION 传感器读数中获得俯仰、横滚、偏航后:
这是 canonicalOrientationToScreenOrientation 函数:
Ok so I figured this out with a lot of help from the Replica Island source and in turn an Nvidia paper.
Once you have the pitch, roll, yaw from the TYPE_ORIENTATION sensor reading:
Here is the canonicalOrientationToScreenOrientation function: