Re: [Algorithms] Nearest point on plane for 2D IK
Brought to you by:
vexxed72
From: Thatcher U. <tu...@tu...> - 2000-08-30 01:56:17
|
From: David Kornmann <da...@ik...> > > > Hmmm ... surely what you want is to find the point on the line closest to > > the center of the sphere (easy to do) and then if that is less than R away > > from the center you have definite intersection, and proceed to compute the > > points at which the line intersects the sphere, and otherwise, you > > conveniently have a point which is in line with the nearest tangential point > > of the sphere, so you can easily find that tangential point. > > Well, computing the point when the ray intersect with the sphere is not a big > deal. > The problem comes when the ray does not intersect: > > I am not looking for the closest surface point on the sphere then, but a point > that > can be described as follow: > > - Take the plane defined with the ray and the center of the sphere. > - Rotate the ray around its origin and along the plane until it is tangent to > the sphere. > - Compute the tangetial point (easy). > > That's what seems to me complicated and which needs to be very accurate. The description is a little confusing, but if I understand correctly, this is not hard to solve. Lets label the points: R = ray origin C = center of circle T = tangent point you're interested in If I catch your meaning, you want C, T, and the ray to all be coplanar. If you make a triangle out of R, C and T, you have a right triangle, with the right angle at T. You can compute the length of the hypotenuse, it's just |RC|, and you know the length of CT because it's equal to the circle's radius. So you can compute the angle CRT, it's just arcsin(|CT| / |RC|). The angle RCT is 90 - CRT. There's some plane which contains all these points; compute its normal: n = normalize((C-R) x ray_direction). To find T, take the vector CR, rotate about n by angle RCT, and make its length equal to the sphere radius. What's the purpose of this? -- Thatcher Ulrich http://tulrich.com |