All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Intersecting lines (Posted on 2003-07-01)
You are given two straight line segments, each defined by the coordinates of its endpoints. Segment AB goes from (Ax,Ay) to (Bx,By) and segment CD - from (Cx,Cy) to (Dx,Dy).

How would you determine if the two line segments intersect?

(Assume that you can't just draw the lines and see)

 See The Solution Submitted by levik Rating: 4.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re(3): Solution | Comment 13 of 20 |
(In reply to re(2): Solution by friedlinguini)

When the fl solution is applied to points that are all colinear, each of the four parenthetical factors is zero, satisfying the equality portion of the <= and therefore reporting an intersection, even if the segments are on disjoint portions of the line they share.

This can be verified using 1,1,2,2,3,3,4,4 as Ax,Ay,Bx,By,Cx,Cy,Dx,Dy or 1,5,2,3,3,1,4,-1.
 Posted by Charlie on 2003-07-04 06:02:41

Please log in:
 Login: Password: Remember me: Sign up! | Forgot password

 Search: Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (2)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2018 by Animus Pactum Consulting. All rights reserved. Privacy Information