如何从旋转矩阵中删除轴?
我有一个 opengl 任意旋转矩阵,想删除 X & Y 轴,只剩下 Z 轴?
这可能吗?有关如何做的任何指示吗?
I have an opengl arbitrary rotation matrix and would like to remove the X & Y axis, leaving me with only the Z axis?
Is this possible? Any pointers on how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是在这里大声思考,但是你不能使用矩阵来旋转像 (1,0,0) 这样的向量,然后执行 atan2(y,x) 看看它旋转了多少,然后构建一个新的矩阵来旋转Z轴差那么多?
Just thinking out loud here, but can't you use the matrix to rotate a vector like (1,0,0), then do atan2(y,x) to see how much it's rotated and then build a new matrix to rotate through the Z axis by that much?
在仅围绕 z 轴的旋转中,z 轴应保持不变。所以上面的建议有点与你想要的相反。
假设您有一个任意 OpenGL 矩阵:
其中 t_i 元素是平移,r_jk 元素是旋转分量。您想要一个如下所示的矩阵:
除非矩阵具有缩放因子或接近奇点,否则您应该能够通过将矩阵的 z 部分归零然后重新标准化列来获得此矩阵。由于 OpenGL 矩阵是列主序:
In a rotation that is only around the z-axis, the z axis should remain unchanged. So the above recommendation is sort of the reverse of what you want.
Let's assume you have an arbitrary OpenGL matrix:
Where the t_i elements are translations and the r_jk elements are components of rotation. You want a matrix that looks like this:
Unless the matrix has scaling factors or is close to a singularity, you should be able to get this by just zeroing out the z parts of the matrix and then re-normalizing the columns. Since an OpenGL matrix is column major order: