旋转轴重新映射?
我使用跟踪设备(仅跟踪旋转,而不跟踪位置)作为输入,并将其旋转矩阵发送到 OpenGL 应用程序。当跟踪器与其轴系对齐时,即当跟踪器面向其 Y 轴且跟踪器的向上方向面向其 Z 轴时,跟踪器发送单位矩阵。如图右侧所示。
但是,如果我旋转跟踪器,我的 opengl 程序中相应的旋转是错误的。为了尝试解决这个问题,我尝试将跟踪器提供的矩阵乘以:
1 0 0 0
0 0 1 0
0 -1 0 0
0 0 0 1
重新映射,但无论我尝试什么,似乎三个旋转之一总是错误的。
是否有一些矩阵可以将我的跟踪器矩阵相乘以获得正确的旋转?
===== 编辑 =====
Android 的 remapCooperativeSystem 似乎实现了我想要的,但我无法理解其中的代码: https://github.com/ android/platform_frameworks_base/blob/master/core/java/android/hardware/SensorManager.java#L1459
I am using a tracking device (only rotation tracked, not position) for input and I send its rotation matrix to an OpenGL application. The tracker sends an identity matrix when it's aligned with it's axis system, i.e when the tracker is facing towards its Y axis and the up direction of the tracker is facing it's Z axis. As seen in the right hand side of the illustration.
If I rotate the tracker however, the corresponding rotation in my opengl program is wrong. To try to remedy that I tried to multiply the matrix provided by the tracker with:
1 0 0 0
0 0 1 0
0 -1 0 0
0 0 0 1
To remap but no matter what I try it seems like always one of the three rotations is wrong.
Is there some matrix that I could multiply my tracker's matrix with to get the rotations right?
===== EDIT =====
Android's remapCoordinateSystem seems to achieve what I want but I can't understand the code in there:
https://github.com/android/platform_frameworks_base/blob/master/core/java/android/hardware/SensorManager.java#L1459
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下工作将矩阵转换为与 OpenGL 一起正常工作。
我不知道为什么它有效,但它有效。
The following worked to translate the matrix to work properly with OpenGL.
I don't know why it worked, but it worked.
我认为您应该尝试使用四元数计算,因为跟踪器可能会沿着其当前(“瞬间”,比如说)轴旋转。因此,我认为最终的旋转将是跟踪器所做的所有旋转的总结。
或者我只是不明白你的“跟踪器”终点的含义=)
I think you should try using Quaternion calculations as tracker may be rotated along its current ('momental' let's say that) axes. So, the final rotation would be the summary of all the rotations made by the tracker, i think.
Or i just did not get the meaning of your "tracker" terminus =)
从评论中,我的理解是,您得到了正确的旋转矩阵,但您希望旋转发生在另一个轴上。例如,您的矩阵绕 z 旋转,但您希望它绕 x 旋转。
要做到这一点,你有很多方法。
一是从一开始就进行正确的轮换。例如,如果从您的设备中您得到旋转应该围绕 z 旋转,但在您的程序中您想将其映射到 x,那么不是围绕 z 旋转,而是围绕 x 旋转!像这样
如果你得到的数据是这样的:
你将有一个这样的地图:
旋转时你写:
或者,你可以以相反的方式得到地图,这对你来说可能更有意义:
然后写:
From the comments, what I understood is that you get the rotation matrix right, but you want the rotation to happen on another axis. For example, your matrix rotates around z, but you want it to be around x.
To do that, you have many ways.
One is to do the rotations right in the first place. For example, if from your device you get that rotation should be around z, but in your program you want to map it to x, well instead of rotating around z, rotate it around x!! Something like
So if the data you get are like this:
you will have a map like this:
When rotating you write:
Alternatively, you could have the map the other way around, which might make more sense to you:
Then write: