给定一个 4x4 齐次矩阵,我如何获得 3D 世界坐标?

发布于 2024-10-14 07:01:49 字数 292 浏览 5 评论 0原文

所以我有一个正在旋转然后平移并再次旋转的对象。我将这些翻译的矩阵存储为对象成员。现在,当我进行对象拾取时,我需要知道该对象的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

故笙诉离歌 2024-10-21 07:01:49

该矩阵是一个 4x4 矩阵,但由于您刚刚获得了一个一维矩阵,因此看起来元素的排列如下:

[0]  [4]  [8]   [12]
[1]  [5]  [9]   [13]
[2]  [6]  [10]  [14]
[3]  [7]  [11]  [15]

旋转部分是左上角的 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:

[0]  [4]  [8]   [12]
[1]  [5]  [9]   [13]
[2]  [6]  [10]  [14]
[3]  [7]  [11]  [15]

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]

熊抱啵儿 2024-10-21 07:01:49

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

北风几吹夏 2024-10-21 07:01:49

所以我是个白痴……我一开始就猜对了。我所需要的只是 [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!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文