Take the 2-minute tour ×  How do I determine whether or not two
lines intersect, and if they do, at what x,y point?
share|improve this question It might help to think of the edges
of the rectangle as separate lines instead of the complete
polygon. –  Ryan Graham Feb 18 '09 at 22:53 You might find some
useful information in the question I previously asked about this
very topic (but with GDI+) at
stackoverflow.com/questions/153592/…. –  Robert S. Feb 19 '09 at
3:20 Do you want to know (A) where two line segments intersect
or (B) whether or not two lines intersect (C) whether or not two
line segments intersect (D) where two lines intersect? Could you
please make your title consistent with your question? –  moose
Feb 23 '13 at 15:29 add comment  16 Answers  There’s a nice
approach to this problem that uses vector cross products. Define
the 2-dimensional vector cross product v × w to be vx wy − vy wx
(this is the magnitude of the 3-dimensional cross product).
Suppose the two line segments run from p to p + r and