DirectX Math 函数混乱
当我检查一些较旧的 DirectX 代码时,我发现了函数 D3DXVec3Transform 和 D3DXVec3TransformCoord。查了一下它们的描述,它们看起来很相似,但我不明白两者之间有什么区别。有人可以解释一下 D3DXVec3Transform 和 D3DXVec3TransformCoord 之间的区别是什么,以及它们背后的数学原理吗?
While I was going over some older DirectX code, I came by the functions D3DXVec3Transform and D3DXVec3TransformCoord. Upon looking up the descriptions for them, they seemed rather similar but I don't see what the difference between the two are. Can someone please explain what is the difference between D3DXVec3Transform and D3DXVec3TransformCoord are, along with the math behind them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

当您通过矩阵变换 3D 向量时,会产生 4D 向量,其中 w!=1
3D 向量可以描述为 4D 向量,其中 w=1。
D3DXVec3Transform 返回 4D 向量,其中 w!=1。
D3DXVec3TransformCoord 获取 4D 向量并将其投影到 w=1 上以使其成为 3D 向量。
编辑:如果对如何进行转换感兴趣,这是我在谷歌上搜索并发现的论文:
http://www.heldermann-verlag.de/jgg/jgg01_05/jgg0404.pdf
When you transform a 3D vector by matrix it results in a 4D vector where w!=1
a 3D vector can be described as 4D vector where w=1.
D3DXVec3Transform returns the 4D vector where w!=1.
D3DXVec3TransformCoord gets the 4D vector and the projects it onto w=1 to make it 3D vector.
EDIT: And here is the paper I google'd and found if interested in how to do the transformation:
http://www.heldermann-verlag.de/jgg/jgg01_05/jgg0404.pdf