code: def intersectingEdges(self, x1y1, x2y2, points):
          
          x1, y1 = x1y1
          x2, y2 = x2y2
          for i in range(4):
              x3, y3 = points[i]
              x4, y4 = points[(i + 1) % 4]
              denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1)
              nua = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)
              nub = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)
              if denom == 0:
                  # This covers two cases:
                  #   nua == nub == 0: Coincident
                  #   otherwise: Parallel
                  continue
              ua, ub = nua / denom, nub / denom
              if 0 <= ua <= 1 and 0 <= ub <= 1:
                  x = x1 + ua * (x2 - x1)
                  y = y1 + ua * (y2 - y1)
                  m = QPointF((x3 + x4) / 2, (y3 + y4) / 2)
                  d = distance(m - QPointF(x2, y2))
                  yield d, i, (x, y)
docs: For each edge formed by `points', yield the intersection
          with the line segment `(x1,y1) - (x2,y2)`, if it exists.
          Also return the distance of `(x2,y2)' to the middle of the
          edge along with its index, so that the one closest can be chosen.