#### Archived

This topic is now archived and is closed to further replies.

# Inverse Kinematics

This topic is 5279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Right now, I''m trying to impliment a basic function of this. Simply, I''m trying to keep a record of the feet positions when the mode is turned on, and make the shins rotate to face towards those points after posing. The problem I''m having is way before I even attempt to rotate the shins. My bones each have their own orientation. Meaning the shin rotating on the Y axis is not twisting. My plan is to use the direction vector from the knee to the foot location to rotate the shin. But I''m not sure how to convert from the world direction vector to one that is relative to the shin''s orientation. Make sense? Of course I''m also not sure how to rotate the shin once I can convert this, so I''m a little lost. Anyone have any experience with this? Any ideas or pointers?

##### Share on other sites
If you want to apply a worldspace rotation to a child object, you need to multiple the worldspace rotation time the inverse of the parent''s worldspace matrix.

For example, you have a worldspace orientation you want to set Mtarget a child matrix to be, Mc. You get the parent''s world matrix by accumulating all the matrices up the chain to the parent, Mpw.

Mc = Mpw.Inverse() * Mtarget

That will give you the local matrix that results in the world target.

For a full IK system, you can incrementally change each bone by limiting the angle and speed of rotation as it converges on the solution.

In your example, the lower leg represents the UP direction. The direction you want the foot to face is the the FORWARD. Cross them to get the RIGHT and you have your target matrix. Use the above formula to get the localspace matrix of the lower leg bone.

If you just want to turn the foot towards a target, take the dot product between the current foot direction and the target. That give you the cos of the angle to turn. You can limit this to a small step so it approaches the target. Check the cross product to get the direction. Then multiple the local matrix by this rotation and you are done.

See my articles on the CCD IK solver for info on this:

http://www.darwin3d.com/gdm1998.htm

##### Share on other sites
Damn, what a great reply. I''ll definitely look into your articles. But you just punched me in the face with the "progressively rotate each joint" bit. That unfolds a great deal of the missing data in my head. English: Big help, thanks!

quote:
Original post by JeffLander If you want to apply a worldspace rotation to a child object, you need to multiple the worldspace rotation time the inverse of the parent''s worldspace matrix.
Well, it''s not just the hierarchy that''s changing the orientation of the bones. It''s the bone''s "offset matrix". From my 4 days of experience with this stuff, I understand the offset matrix places the bone at a specific orientation, in addition to placing the joint at the zero point.

Character Studio seems to have placed mine so that the thigh rotating on Y goes forward-back (aka, walking), and not twist as with the rest of my world. For all bones, Y always seems to be forward-back, or bend. X is twist, and Z is side-to-side. And it makes no difference if the arm is stretched up/down in the creation process as opposed to left/right. X is always twist, Y is always bend.

So you are correct about hierarchy order, but doesn''t the offset matrix also have something to do with converting world->bone orientation and vice versa?

Thanks again for the help

##### Share on other sites
I think I understand your question.

If you use 4x4 matrices to represent both the orientation and the offset displacement. For example a shin bone might be of some length (say 1). In my example, we will consider that the normal bone orientation is with the Z axis looking down along the bone. So the matrix for the shin would start with a translation of (0,0,1). To bend the knee you would then also apply a rotation on the bone. Combine the translation with the rotation to make a single 4x4 matrix that describes that bone.

With all the bones described as 4x4 matrices, the math works out like I described earlier.

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633420
• Total Posts
3011790
• ### Who's Online (See full list)

There are no registered users currently online

×