我不太理解 C# 中的 Matrix.Multiply(Matrix m) 方法。
假设我有 2 个矩阵。 1个矩阵在世界空间,1个矩阵在局部空间,现在我想将世界空间变换到局部空间或者从局部空间变换到世界空间,我应该用Multiply方法做什么?
Matrix world = ....
Matrix local = ...
world.Multiply(local)
// It means world*local or local*world and it will transform world space to
// local or from local to world space?
提前致谢。
最佳答案
如果您想将一个矩阵转换为另一个矩阵,则不需要将矩阵相乘。您想要找到需要将一个乘以从一个到另一个的矩阵。本质上,您想要解方程:
W * X = L
其中 W
是您的世界矩阵,L
是您的本地矩阵。您正在寻找矩阵X
。求解X
:
W * X * 1/L = I
其中 I
是单位矩阵,1/L
是 L
的逆矩阵,因此:
X = 1/W * L
请注意,矩阵乘法不可交换,因此W * L
与L * W
不同。
关于c# - C# 中的矩阵乘法方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2051403/