Re: [Algorithms] Nearest point on plane for 2D IK
Brought to you by:
vexxed72
From: <ro...@do...> - 2001-03-02 04:41:04
|
Jeff Lander wrote: >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.=20 > 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=20 >little math routine for the magazine. =20 >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.=20 > 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.=20 > 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. =20 >The method is to determine the plane that B is allowed to rotate,=20 >then project T into that plane. Then I solve for the rotation angle. > >To project T onto B's free rotational plane: > >N =3D free axis of rotation > >V =3D T - B // Creates vector from base to target It is not at all clear to me what you mean by B. Is it a pure vector (like N) or is it the position vector of a point (like T). Does it represent the position of a bone or the relative positions of the two ends of the bone?=20 This equation only makes sense if B is the position vector of a point. In that case, it tells where the bone is, but not how it is oriented. But also, in this case, "B's free rotational plane" is without meaning. >P =3D T - N ( N dot V) // Project V onto axis and subtract that from the= target > I think that your criterion for P is that it be perpendicular to N. This P satisfies that criterion, that is, P is the perpendicular projection of V on the plane perpendicular to N, only in the special case that B is perpendicular to N, which I think is probably not true, in general, for the systems you want to work with. The proper vector formula for the perpendicular projection of V on the plane perpendicular to N is=20 P =3D V - (N dot V)N and it holds independently of how you construct V. |