I have a situation where I'm trying to push the output of an IK solver back into a user editable joint hierarchy (which stores components as it's primary source), and I'm not sure how to go about it.
My IK solver returns three world space transforms representing the position and orientation of a chain of joints (0,1,2).
A: I need to turn this into a hierarchy so that transform 2 is local to transform 1, and transform 1 is local to transform 0. Now I have local transforms for each joint.
B: Further: I need to decompose each joint's new local matrix into source Translation, Rotation and Scale.
Can anyone give me some tips for each step? I have some ideas, but I'm worried that to do B I need to particularly careful with A.
For example if I get my world matrices like this:
M4 world_mats = IK_solve( ikparams );
And then convert them to local like this:
M4 local_mats = GenerateLocalChain( world_mats );
And then extract components:
Scale s; Rotation r; Translate t; foreach ( matrix in local_mats ) Decompose( matrix, s, r, t );
How can I implement the
Decompose() function to match matrices created in