docs: def lines_intersect(pt1_p, pt2_p, pt1_q, pt2_q):
      '''Return true if two line segments intersect
      pt1_p, pt2_p - endpoints of first line segment
      pt1_q, pt2_q - endpoints of second line segment
      '''
      #
      # The idea here is to do the cross-product of the vector from
      # point 1 to point 2 of one segment against the cross products from 
      # both points of the other segment. If any of the cross products are zero,
      # the point is colinear with the line. If the cross products differ in
      # sign, then one point is on one side of the line and the other is on
      # the other. If that happens for both, then the lines must cross.
      #
      for pt1_a, pt2_a, pt1_b, pt2_b in ((pt1_p, pt2_p, pt1_q, pt2_q),
                                         (pt1_q, pt2_q, pt1_p, pt2_p)):
          v_a = pt2_a-pt1_a
          cross_a_1b = np.cross(v_a, pt1_b-pt2_a)
          if cross_a_1b == 0 and colinear_intersection_test(pt1_a, pt2_a, pt1_b):
              return True
          cross_a_2b = np.cross(v_a, pt2_b-pt2_a)
          if cross_a_2b == 0 and colinear_intersection_test(pt1_a, pt2_a, pt2_b):
              return True
          if (cross_a_1b < 0) == (cross_a_2b < 0):
              return False
      return True