Looking for the C# XNA equivalent of this function this question is in relation to the below post (Currently Unanswered),
world velocity to local (ship might be flying backward so need worlds negative velocity etc.)
This problem which i am also having is easily solved in unity by the above function, if anyone could supply the mathematical code behind this function or write a small function which achieves the same result, that person would be !!! AWESOME !!! As we have been trying to fix this problem for days.
For a detailed explanation of the problem see the post of my friend listed above.
Thank you all in advance <3
You can get the inverse of a matrix in XNA and then use it by doing this:
Matrix inverseMatrix = Matrix.Inverse(myMatrix);
Vector3 result = Vector3.Transform(myVector, inverseMatrix);
From my understanding, though, you want to ignore the translation when getting the inverse. So you've got a direction only (basically this accounts for rotation, scale, etc). I've not tested this myself, but I think this should do what you want:
Matrix copyOfMyMatrix = myMatrix;
copyOfMyMatrix.Translation = Vector3.Zero; // reset the translation components
Matrix inverseMatrix = Matrix.Inverse(copyOfMyMatrix);
Vector3 result = Vector3.Transform(myVector, inverseMatrix);