Sign in to follow this  
papa

Global to local transformation - matrices, bones

Recommended Posts

Hi Before I ask about transformations in Skeletal animation I just want to make sure I am right in this: See below an image. There are 3 points (joints) drawn (ie. 2 bones in total) in global coordinates. Ok. these points p1, p2, p3 are drawn in global coordinates (see values X,Y). Now I would like to obtain values for each point in local coordinates. So p1 in local coordinates would be same as in global as this is the root so p1(1.0,0.0), p2 in local would be p2(1.0, 2.0) and p3 in local would be (1.0, 1.0) is it right? Please confirm as working all day withmatrices I think I lost my mind... Ok. Now the hard question. Say each point is transformed using matrices (in global coord) as they appear on the above image. Now I would like to work out local matrix for each of these points. Would it be correct to calculate it this way:
for( int i=0; i<3; i++)  // 3 points as on image
{
    if( i > 0 )
    { 
         Matrix mx_global = pnt[i].globalMatrix;          // current joint's global matrix
         Matrix mx_parent_global = pnt[i-1].globalMatrix; // parent joint global matrix

         // Now I need to work out the local matrix for current i'th joint
         mx_parent_global.MatrixInverse(); // inverses mx_parent_global
        Matrix mx_local = mx_global * mx_parent_global; 
   } 
   else
       mx_local = mx_global;  // if root then it should be same as global
}




Could you please tell me if I am wrong how to calculate this properly so I could get for each point from global matrix to local matrix. I also cant imagine those points transformed in local. Where would they appear on the above image's grid? What would be the values of these points. Maybe if I know these values it will be easier for me to imagine how all this works. Thank you in advance. [Edited by - papa on September 21, 2004 11:32:37 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by papa
So p1 in local coordinates would be same as in global as this is the root so p1(1.0,0.0), p2 in local would be p2(1.0, 2.0) and p3 in local would be (1.0, 1.0) is it right? Please confirm as working all day with matrices I think I lost my mind...

Looks good to me, your mind's still intact.

Quote:
Original post by papa
Could you please tell me if I am wrong how to calculate this properly so I could get for each point from global matrix to local matrix. I also cant imagine those points transformed in local. Where would they appear on the above image's grid? What would be the values of these points. Maybe if I know these values it will be easier for me to imagine how all this works. Thank you in advance.

Your code is correct, to calculate the difference between two matrices you multiply one by the inverse of the other. This isn't commutative, but you've used the correct ordering above.

You're drawing examples of translation in a 2D world so the local results are exactly the points you have listed above. You can picture what the local graphs would look like if you take each line segment (bone) and move the parent dot to the origin. The local transform is exactly the the distance (or orientation) necessary to move from parent to child.

You probably figured this out days ago, but I thought I'd write anyway to affirm that you are correct because you didn't have any replies.

Share this post


Link to post
Share on other sites
Thank you Cauthon for help. Yes the reason why I asked coze even though I had the theory done the result on screen was different as I 've made some silly mistake elsewhere thus this confusion. But anyway its sorted now. Thank you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this