什么';XNA(C#)中Vector2.Transform()和Vector2.TransformNormal()的区别是什么
我正在用XNA(C#)开发一个游戏,我想知道如何使用2个版本的转换。在我看来,这些功能的工作是: (假设向量源于矩阵.Identity)什么';XNA(C#)中Vector2.Transform()和Vector2.TransformNormal()的区别是什么,c#,xna,game-engine,game-physics,C#,Xna,Game Engine,Game Physics,我正在用XNA(C#)开发一个游戏,我想知道如何使用2个版本的转换。在我看来,这些功能的工作是: (假设向量源于矩阵.Identity) vector2resultvec=Vector2.Transform(sourceVector,destinationMatrix)用于位置向量的变换 vector2resultvec=Vector2.TransformNormal(sourceVector,destinationMatrix)用于变换速度向量 这是真的吗?。谁知道详细的解释,请帮忙 通过
vector2resultvec=Vector2.Transform(sourceVector,destinationMatrix)代码>用于位置向量的变换
vector2resultvec=Vector2.TransformNormal(sourceVector,destinationMatrix)代码>用于变换速度向量
这是真的吗?。谁知道详细的解释,请帮忙 通过变换,函数将源向量与生成的矩阵相乘
用于表示二维或三维空间中位置的向量。具体来说,这将采用表示坐标的反转矩阵的转置(T运算符)李>Transform()
retVec=T(M^-1)x srcVec
用于方向、切线向量。这保留了矩阵TransformNormal()
retVect=srcVec x M
将一个向量从一个矩阵/坐标变换到另一个矩阵/坐标(如M1到M2):retVec=按M1变换->然后按M2逆变换:
Vector2 retVec = Vector2.Transform(vectorInSource, M1);
Matrix invertDestMatrix = Matrix.Invert(M2);
outVect= Vector2.Transform(retVec , invertDestMatrix);
简单的答案是—
Vector2.Transform()
在
Vector2.TransformNormal()
仅将矩阵的缩放和旋转部分应用于向量。您是否尝试阅读文档?快速搜索显示,Transform
用于位置向量,TransformNormal
用于法向量。法向量是什么?我从以下内容中读取简短描述:。但不是很清楚,你可能想读一点线性代数。如果你打算做游戏编程,你需要知道它是什么。参见Wikipedia(谷歌上的第二个搜索结果)。法向量是长度为1的向量(通过毕达哥拉斯定理)——你用它们来指示方向(而不是位置或速度等)。