I dont really understand the method Matrix.Multiply(Matrix m) in C#.
Let say I have 2 matrices. 1 matrix is in world space and 1 matrix in local space, now I want to transform world space to local space or from local space to world space, what should I do with the Multiply method?
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?
Thank in advance.
You don’t want to multiply the matrixes if you want to transform one matrix into the other. You want to find the matrix you need to multiply one by to go from one to the other. Essentially, you want to solve the equation:
Where
Wis your world matrix andLis your local matrix. You’re looking for matrixX. Solving forX:Where
Iis the identity matrix and1/Lis the inverse ofLSo:Note that matrix multiplication is not commutative, so
W * Lis not the same, in general, asL * W.