Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Line-Line Interesection
Index -> Off Topic
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Flikerator




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Cervantes




PostPosted: Sun Jun 25, 2006 6:08 pm   Post subject: (No 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).
Flikerator




PostPosted: Mon Jun 26, 2006 5:26 pm   Post subject: (No 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.
Display posts from previous:   
   Index -> Off Topic
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: