This is a complicated question. I have a math formula of how to convert a rotation matrix from a bone to result in the same rotation for another bone on another skeleton given that skeleton has an already different rotation and a different coordinate axis orientation.
I have tried to implement this in Blender, and I am 100 percent sure I have the correct matrices, but the problem is that the result ends up the wrong rotation.
The problem is this. The bone at the first frame, should be multiplied by the inverse of the bone in bindpose, meaning the bone in the first frame. This results in the identity matrix "sbindposeinverse * srotation". Since the rest of the transformations depends on this matrix to be unique or the target bone to be unique the result is the identity matrix. The target bone is in rest position at the first frame so it has no rotation. But I need the rotation from the first frame of the source bone. What am I missing in logically?