From: Robin Chapman Newsgroups: sci.math Subject: Re: Shortest distance between 3d lines Date: Wed, 11 Mar 1998 10:10:35 -0600 In article <01bd4b90\$f1815240\$66ad6ccf@richards.s-vision.com>, "Richard Shields" wrote: > > This might be a frequently ask question but couldn't find any reference to > it in the FAQ for this group so... > > Given two lines defined by four points (p1 and p2 define line 1 and p3 and > p4 define line 2) in three dimensional space how do you > 1) determine the shortest distance between the two lines, > 2) determine the point on line 1 that is closest to line 2. This is a standard exercise in vector algebra. One can give the equations of the lines in vector form as r = p_1 + t a_1 and r = p_3 + u a_2 where t and u are real parameters and a_1 = p_2 - p_1 and a_2 = p_4 - p_3. Let's assume the lines are not parallel. If the closest points on the lines are Q_1 and Q_2 then the segment Q_1 Q_2 is perpendicular to both lines. Thus c = (a_1 x a_2)/|a_1 x a_2| is a unit vector in the direction Q_1 Q_2. (Here x denotes the vector product.) Then line 1 is contained in the plane r.c = p_1.c and line 2 in r.c = p_3.c. The distance between these planes, and between the lines 1 and 2 is |p_1.c - p_2.c|. To determine Q_1 and Q_2 set Q_1 = p_1 + t a_1 and Q_2 = p_3 + u a_2. Then Q_1 - Q_2 is perpendicular to a_1 and a_2 and so a_1.Q_1 = a_1.Q_2. and a_2.Q_1 = a_2.Q_2. These give two linear equations for Q_1 and Q_2 which can be solved to find t and u and so Q_1 and Q_2. Robin Chapman + "They did not have proper Department of Mathematics - palms at home in Exeter." University of Exeter, EX4 4QE, UK + rjc@maths.exeter.ac.uk - Peter Carey, http://www.maths.ex.ac.uk/~rjc/rjc.html + Oscar and Lucinda -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading