How to find the reverse of a formula when dealing with matrices

54 Views Asked by At

I currently have a formula that deals with animation. I'm not even quite sure what I'm asking but I'd rather just show what the issue is by sharing this google sheet with formula.

I am dealing with 4x4 matrices and a hierarchy of bones.

I currently use 2 formulas, 1 for a bone with no parent and another for a bone with a parent...

A = bone matrix
B = animation frame matrix
bone0|noparent| X = (A * B)
bone1|bone0   | Y = (C * D) * (inverse of X)
bone2|bone0   | Z = (E * F) * (inverse of Y)
bone3|bone2   | M = (G * H) * (inverse of Z)

But my current problem is I want to reverse this. Instead of finding X and Y. I need to find B,D,F and H with X, A, Y, C, Z E, M and G provided. Something like:

X = (A * ?)
Y = (C * ?) * (inverse of X)
Z = (E * ?) * (inverse of Y)

How do I reverse the equation/formula?

I have a current formula that works for bones that has 1 parent or no parent. Unfortunately I cannot figure out what I'm missing when computing with a bone with parent whose parent also has a parent.

On my sheet I got a wrong result for bone 3 and I also added the expected result. My problem is I cannot figure out the correct formula to turn my wrong result to the expected one.

This is currently a challenge to myself in making a game without using engines like Unity.

Sorry, I am not sure how to actually ask the question because I don't know the technical terms.

1

There are 1 best solutions below

1
On BEST ANSWER

If these were matrices in the linear algebra sense, the following would be the answer:

If you are given $A$ and $X$ then $$ B = A^{-1}X $$ (make sure to multiply on the left here).

If you are given $A$ and $Y$, then $Y$ had better be the identity matrix since $X = AB$ and $$ Y = ABX^{-1} = AB (AB)^{-1} = ABB^{-1}A^{-1} = A I A^{-1} = I $$ and you cannot recover $X$.

One more thing -- I suspect that these parent/child matrices are more like matrices in the graph theory sense (entry is 1 if this one connects (via parentage) to that one), so the question is a bit ill-posed.