My Math Forum Line segments-distance
 User Name Remember Me? Password

 Algebra Pre-Algebra and Basic Algebra Math Forum

 February 6th, 2011, 04:54 AM #1 Newbie   Joined: Feb 2011 Posts: 1 Thanks: 0 Line segments-distance How can I calculate the shortest distance between two line segments? if they are skew? line1:A[x1,y1,z1],B[x2,y2,z2] line2:C[x1,y1,z1],D[x2,y2,z2]
 February 6th, 2011, 09:23 AM #2 Senior Member   Joined: Nov 2010 Posts: 502 Thanks: 0 Re: Line segments-distance A key thing to note is that this segment will be perpendicular to both.
February 6th, 2011, 11:56 AM   #3
Senior Member

Joined: Feb 2009

Posts: 1,519
Thanks: 3

Re: Line segments-distance

This is a difficult task, best left to a math library, and I'll direct you to this algorithm.

Quote:
 A key thing to note is that this segment will be perpendicular to both.
Not necessarily, which is the problem.

February 6th, 2011, 02:24 PM   #4
Senior Member

Joined: Nov 2010

Posts: 502
Thanks: 0

Re: Line segments-distance

Quote:
Originally Posted by aswoods
This is a difficult task, best left to a math library, and I'll direct you to this algorithm.

Quote:
 A key thing to note is that this segment will be perpendicular to both.
Not necessarily, which is the problem.
I challenge you to find me an example. Not an angry challenge - just that I am somewhat confident. To motivate my argument, I will note that by taking the cross product of the directions of the two lines, we can find a particular plane. And by placing one copy of this plane on one line, and another on the other line, we have two parallel planes. Finally, by finding the distances between the two planes (which is more standard, I believe), we will see a perpendicular from one line to the other - and by the triangle inequality, any non-perpendicular will be longer.

 February 6th, 2011, 02:25 PM #5 Senior Member   Joined: Nov 2010 Posts: 502 Thanks: 0 Re: Line segments-distance In addition, I direct you to the following links - which give simple ways to accomplish this (different than the one I proposed, however, but confirming the mutual perpendicular). http://www.coventry.ac.uk/ec//jtm/slides/8/sld8p5.pdf http://members.tripod.com/Paul_Kirby/vector/Vclose.html
 February 6th, 2011, 02:33 PM #6 Global Moderator   Joined: May 2007 Posts: 6,255 Thanks: 507 Re: Line segments-distance Point P(s) on line 1, P(s)= A + (B-A)s Point Q(t) on line 2, Q(t)= C + (D-C)t Let f(s,t) = |P(s)-Q(t)|^2 Compute ?f/?s and ?f/?t and set them both = 0. Solve the simultaneous equations for s and t. (Notation: cap. letters for vectors, lower vase for scalars.)
February 6th, 2011, 03:56 PM   #7
Senior Member

Joined: Feb 2009

Posts: 1,519
Thanks: 3

Re: Line segments-distance

Quote:
 Originally Posted by DLowry I challenge you to find me an example. Not an angry challenge - just that I am somewhat confident.
It's about segments not lines. If the first segment is (0,0,0)-(0,0,1), and the second segment is (0,0,2)-(0,0,3), then the shortest distance between the segments is 1, and the joining segment is (0,0,1)-(0,0,2). In this example, the two segments are on the same line, but it is not necessary for the problem to arise, even in 2D.

February 8th, 2011, 09:09 PM   #8
Senior Member

Joined: Nov 2010

Posts: 502
Thanks: 0

Re: Line segments-distance

Quote:
Originally Posted by aswoods
Quote:
 Originally Posted by DLowry I challenge you to find me an example. Not an angry challenge - just that I am somewhat confident.
It's about segments not lines. If the first segment is (0,0,0)-(0,0,1), and the second segment is (0,0,2)-(0,0,3), then the shortest distance between the segments is 1, and the joining segment is (0,0,1)-(0,0,2). In this example, the two segments are on the same line, but it is not necessary for the problem to arise, even in 2D.
Aha - I yield defeat. I hadn't considered this.

 Tags line, segmentsdistance

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post nilesh33 Algebra 0 February 20th, 2013 11:17 AM Jmlee19 Calculus 5 December 6th, 2012 03:23 PM master555 Applied Math 0 December 2nd, 2011 06:56 PM 1101 Algebra 4 February 22nd, 2011 12:43 PM Cheesy74 Algebra 4 November 17th, 2009 06:23 AM

 Contact - Home - Forums - Cryptocurrency Forum - Top