Computer Science Canada

Line-Line Interesection

Author:  Flikerator [ Sun Jun 25, 2006 2:40 pm ]
Post subject:  Line-Line Interesection

How do you tell if two lines intersect? I don't care where, but whether they intersect once or not at all. This was a part of my math course (I think) but we handed in our text books. Looking it up online is basically Gauss-Jordan method, or solving with equations. I can do it that way, but Im programming it.

Author:  Tony [ Sun Jun 25, 2006 3:21 pm ]
Post subject:  Re: Line-Line Interesection

Flikerator wrote:
How do you tell if two lines intersect? I don't care where

The only way two lines will not intersect are if they are parallel (same slope) and are not the same line. So just compare slopes of the lines and some arbitrary point.

Author:  Cervantes [ Sun Jun 25, 2006 6:08 pm ]
Post subject: 

If the linse are in two dimensions, Tony's solution works. But if you're in three dimensions, you have to work harder. Darn ol' skew lines.

Also, are these lines you are dealing with, or line segments? I wasted a little bit of time on the CCC this year because at first I was only checking slopes (and a single point to check for coincidence if the slopes were equal).

Author:  Flikerator [ Mon Jun 26, 2006 5:26 pm ]
Post subject: 

Line-Segements in two Dimensions. Sorry, im dealing with just the segements so I never thought to mention it. Im pretty sure we dealt with this but without the text book I have no idea if we did.


: