def segments_intersect(s1, s2):
(x1, y1), (x2, y2) = s1<EOL>(x3, y3), (x4, y4) = s2<EOL>den = ((y4-y3) * (x2-x1)) - ((x4-x3)*(y2-y1))<EOL>n1 = ((x4-x3) * (y1-y3)) - ((y4-y3)*(x1-x3))<EOL>n2 = ((x2-x1) * (y1-y3)) - ((y2-y1)*(x1-x3))<EOL>if den == <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT>u1 = n1/den<EOL>u2 = n2/den<EOL>return <NUM_LIT:0.0> <= u1 <= <NUM_LIT:1.0> and <NUM_LIT:0.0> <= u2 <= <NUM_LIT:1.0><EOL>
Return *True* if *s1* and *s2* intersect.
*s1* and *s2* are defined as::

  s1: (x1, y1), (x2, y2)
  s2: (x3, y3), (x4, y4)