矩阵*向量与向量*矩阵相比意味着什么
如果我这样做 positionVector*worldMatrix
位置将转换为世界空间。 但是如果我在 3d 空间中以相反的方式(worldMatrix*positionVector
)做,会发生什么?
我注意到结果与第一个不同。 我已经用谷歌搜索了矩阵,数学,他们解释了很多,但不是这个,至少我找不到它。
if I do positionVector*worldMatrix
the position is transformed into world space.
But what happens if I do it the other way around (worldMatrix*positionVector
) in terms of 3d space?
I noticed the result is different to the first one. I already googled about matrix, math they explain a lot but not this one, at least I couldn't find it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如其他人指出的那样 - 交换乘法的顺序相当于乘以转置。 事实上,旋转矩阵是一种特殊类型的矩阵,称为正交矩阵,这可以让你整齐的属性数量。
最有趣的可能是矩阵的转置是其逆矩阵。 对于你的世界变换乘以倒数相当于在世界空间中占据一个位置并将其拉入与变换相关的对象的局部坐标中。
举个例子,考虑一个在世界中任意定向的盒子 - 乘以逆世界变换可以(当然完全依赖于应用程序:))将你置于一个轴对齐的空间中,如果你有兴趣寻找与在盒子的本地空间中进行计算的其他对象将使这变得更容易。
As others have indicated - swapping the order of the multiplication is equivalent to multiplying by the transpose. As it happens, rotation matrices are a special type of matrices known as orthogonal matrices this gets you a number of neat properties.
The most interesting is probably that the transpose of the matrix is its inverse. For your world transform multiplying by the inverse is equivalent to taking a position in world space and pulling it into the local coordinates of the object that transform is associated with.
As an example, consider a box oriented arbitrarily in the world - multiplying by the inverse world transform could (entirely application dependant of course :)) put you in a space where it is axis aligned, and if you were interested in looking for collisions with other objects doing the calculations in the box's local space would make this easier.
在矩阵向量中,向量将被解释为列向量。 在向量矩阵中,它将被解释为行向量。 2x2 示例:
如您所见,结果不同。
顺便说一句,执行一个与转置矩阵后执行另一个相同。
就 3D 空间而言,如果您将两个选项之一视为线性变换,我不知道另一个选项是否有任何合理的解释。 这个维基百科部分介绍了相关内容,但它超出了我对线性代数的理解。
In matrixvector, your vector will be interpreted as a column vector. In vectormatrix, it will be interpreted as a row vector. 2x2 examples:
As you can see, the result is different.
Incidentally, doing the one is the same as doing the other after transposing the matrix.
In terms of 3D space, if you consider one of the two options to be a linear transformation, I don't know if there is any sensible interpretation for the other one. This Wikipedia section says things about it, but it is beyond my understanding of linear algebra.
(矩阵 * 向量) 等价于 (向量 * 转置(矩阵))
(matrix * vector) is equivalent to (vector * transpose(matrix))
矩阵数学规则:
给定矩阵A和B,大小为MxN和OxP,
另一个重要规则是矩阵乘法不可交换。 A * B != B * A
通常在计算机图形学中,位置向量是一个 4x1 矩阵,并且世界视图矩阵是正方形,4x4。 因此,您应该预期世界视图矩阵与位置向量的预乘将是未定义的。 将世界视图矩阵应用到位置向量的正确方法是按其他顺序,将位置向量与世界视图矩阵预乘。 (我在这里说的是数学)
要获得矩阵数学的更多乐趣,请查看此教程。
Matrix math rules:
Given matrices A and B, with sizes MxN and OxP,
Another important rule is that matrix multiplication is not commutative. A * B != B * A
Typically in computer graphics, the position vector is a 4x1 matrix, and the world view matrix is square, 4x4. Thus you should expect that pre-multiplying the world view matrix with the position vector would be undefined. The proper way to apply the world view matrix to the position vector is in the other order, pre-multiplying the position vector with the world view matrix. (I'm speaking mathematically, here)
For more fun with matrix math, check out this tutorial.