[Algorithms] Nearest point on plane for 2D IK
Brought to you by:
vexxed72
From: Jeff L. <je...@di...> - 2000-08-29 17:35:30
|
Since we were talking about skeleton animation, I have a question. For my IK system, I prefer to use actual 2D joints where appropriate rather then use the general 3D form and limit with DOF restrictions. I have received some email asking me how to do this with my CCD IK routine so I wanted to write up a paragraph on the little math routine for the magazine. I think it is pretty obvious to people familiar with vector math, but I have found that many developers don't have the background and need some help. I will put this in with my continuing series on why dot product is your friend. I want to sanity check it to make sure this is a good, fast way to do this. I know that it works but it may not be the best method. Given a bone object in 3 space, B, and a desired 3D target to attempt to reach, T. The method is to determine the plane that B is allowed to rotate, then project T into that plane. Then I solve for the rotation angle. To project T onto B's free rotational plane: N = free axis of rotation V = T - B // Creates vector from base to target P = T - N ( N dot V) // Project V onto axis and subtract that from the target Now, P is my new target point for the IK routine. Continue as usual, dot product to get the angle to rotate, ... I will explain why this works and such but you get the idea. -Jeff |