给定一个 4x4 齐次矩阵,我如何获得 3D 世界坐标?
所以我有一个正在旋转然后平移并再次旋转的对象。我将这些翻译的矩阵存储为对象成员。现在,当我进行对象拾取时,我需要知道该对象的 3D 世界坐标。
目前我已经能够像这样获取对象的位置
坐标[0] = FinalMatrix[12];
坐标[1] = FinalMatrix[13];
坐标[2] = 最终矩阵[14];
这为我提供了对象的正确位置,但我也想考虑旋转。
任何帮助都会很棒...
So i have an object which is getting rotated then translated and rotated again. I am storing a matrix of these translations as an object member. Now when i come to object picking i need to know the 3D world coords of this object.
Currently i have been able to get the position of the object like so
coords[0] = finalMatrix[12];
coords[1] = finalMatrix[13];
coords[2] = finalMatrix[14];
This is giving me the correct positions of the objects but i want to take the rotations into account as well.
Any help would be great...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该矩阵是一个 4x4 矩阵,但由于您刚刚获得了一个一维矩阵,因此看起来元素的排列如下:
旋转部分是左上角的 3x3 矩阵 参见此处,因此在您的情况下它将是元素
[0]-[2]
,[4]-[6]
和[8]-[10]
The matrix is a 4x4 matrix, but as you've just got a single dimensional matrix it appears that the elements are arranged as follows:
The rotation part is the top left 3x3 matrix see here, so in your case it would be elements
[0]-[2]
,[4]-[6]
and[8]-[10]
http://www.euclideanspace.com/maths/geometry/affine/matrix4x4 /index.htm - 这是 4x4 矩阵如何工作的解释。第一个小 3x3 - 是旋转矩阵。除最后一个元素外的最后一列是平移向量。 element[4, 4] 是比例因子。在链接中阅读更多相关信息
http://www.euclideanspace.com/maths/geometry/affine/matrix4x4/index.htm - here is the explanation how the 4x4 matrices work. The first minor 3x3 - is a rotation matrix. The last column except last element is a translation vector. And element[4, 4] is a scale factor. Read more about this at the link
所以我是个白痴……我一开始就猜对了。我所需要的只是 [12][13][14] 中的位置数据。我的代码中有几个愚蠢的错误,其中之一是我的光线交叉点没有足够的迭代...现在全部排序了,哈哈,我踢自己..哈哈,无论如何,谢谢你们!
So I am an idiot... i had it correct in the first place. All i needed was the position data in [12][13][14]. I had a couple stupid bugs in my code, one of which was not having enough iterations on my ray intersection...All sorted now lol im kicking myself..haha thanks anyway guys!!