• 10
• 13
• 18
• 27
• 9

# Extracting an input matrix from a final matrix

This topic is 2136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This seams like it would be rather simple, but I'm having some trouble. I have a few matrices:
output = the end result of this operation JointToOrigin = some input matrix OriginToJoint = The inverse of JointToOrigin parent = parent->output (the output of this output's parent) State = An input matrix, and the one I want to extract from output

This is how output is computed with these matrices:
MATRIX output; output = JointToOrigin * State; output = output * OriginToJoint; output = output * parent;

Now assuming all of these matrices have the same values as the time of above, is it possible to determine the value of the original -State- matrix? Can anyone help me determine the order I would need to do this in? This is what I have tried, and I've tried re-arranging them, but I haven't had any luck:
State = Inverse(parent) * output; State = State * JointToOrigin; // because JointToOrigin is the inverse of OriginToJoint State = OriginToJoint * State; // because it is the inverse

Thank you for any help Edited by Kest

##### Share on other sites

This is how output is computed with these matrices:
MATRIX output; output = JointToOrigin * State; output = output * OriginToJoint; output = output * parent;

Did I understand correctly? You have the equation
 output = JointToOrigin * state * OriginToJoint * parent; 
which equals
 output = JointToOrigin * state * JointToOrigin^(-1) * parent; 
and you want to solve for the matrix 'state', given that you know the matrices 'output', 'JointToOrigin' and 'parent'?

In that case, the answer is by straightforward manipulation
 state = JointToOrigin^(-1) * output * parent^(-1) * JointToOrigin; 

##### Share on other sites
Yes, that is correct. And thank you very much for the correct answer.

Just out of curiousity, and not really related to my original question, is there any way to turn this computation:
output = JointToOrigin * State * OriginToJoint

Into a single (matrix * matrix) multiply? For instance, can I pre-calculate a matrix using JointToOrigin that will allow me to perform this step with one multiply instead of two?

Thank you again for your help.

##### Share on other sites
Unfortunately this is not possible in general. Conjugation (multiplication by x*c*x^-1) is a whole different type of operation than standard left or right multiplication, and they are not interchangeable.

If I was trying to optimize that, I'd make sure I was using an efficient inversion routine (see float3x4::InverseOrthonormal or float3x4::InverseOrthogonalUniformScale depending on if you have scaling or not), and then use SSE to optimize the matrix*matrix multiplication.