How to get bone rotation between two matrices?

Before the question a bit of a background...

I have a mesh, and vertex groups as well for it's bones. Before placing the bones, I moved the vertices of the mesh, so every vertex.co += m.translation, where m was a matrix containing a starting position for each bone. Because Blender is handling bones different then the system I was working on before, I had to do a conversion: while I have points in old system, Blender has "sticks" (what are described with two points: with a head and a tail). I was able to create an armature good enough just by telling Blender that a bone's head is the parent's tail, etc. There was no rotation applied on starting position. The stuff seemed to be fine: I even verified the result in Ultimate Unwrap 3D Pro, and seemed to be all right. So far it was too easy. Then it came for animations...

I had to do a bit research: made a primitive mesh and armature with a script and started to learn how Blender handles the bones and animations. I learned, that I can use a .matrix to rotate, and scale the bone relative to the parent. Using translation led to no good, since the bones are connected and so the parent's tail is the inherited's head, so if I would want translation I had to set length of the bone. In my old system everything was different, not just handling the bones. No head or tail, just matrices, so when I say a bone is in m then all the vertices are to be multiplied with it. m is not relative to parent, but the object.

So my question is the conversion... let's see only one bone in pose mode.

I have two matrices in my old system m1 and m2, where m1 is parent. I can make a bone in Blender system called b with a .head of m1 and .tail of m2. Both m1 and m2 contain translation, rotation and scaling. In Blender I think it is like b.head = m1.translation and I am to point the bone to m2.translation, but with m1. rotation and scaling data, but ignoring m2. translation and scaling, because that is the inherited bone's property. My guess is that I am to modify the rotation value with m2.translation value somehow, but I do not know how.

I am not good enough in BPY yet and Math ever, that is why I would like to ask for help with this.

• I think you need to give quite a bit more detail. "how I can get the bone's matrix value?" - Editmode? Object Mode? Pose Mode?, What is the matrix relative to?, The question title asks for the "bone rotation between two matrices?", but the question isnt asking about rotation at all. Ideally you could give a sample script which currently fails, then its easier to test and show the solution. (also probably more useful to others) – ideasman42 Oct 12 '13 at 19:57
• Thank you for the comment, I will edit the question (had no time for details this time). – Zéiksz Oct 13 '13 at 9:21
• @Zéiksz I had a similar issue here blender.stackexchange.com/questions/3549/…. This is the first step to convert position data from kinect into rotation matrices. This might be helpful for you since it shows how to calculate rotation from positions. – stacker Oct 28 '13 at 6:04
• Any updates to this quesiton? – Matt May 13 '16 at 21:19
• No, and as far I remember I was unable to solve the issue those days. – Zéiksz May 17 '16 at 7:18