def addLoopLoopsIntersections(loop, loopsLoopsIntersections, otherLoops):
 for pointIndex in xrange(len(loop)):
  pointBegin = loop[pointIndex]
  pointEnd = loop[((pointIndex + 1) % len(loop))]
  addLineLoopsIntersections(loopsLoopsIntersections, otherLoops, pointBegin, pointEnd)

def addLoopLoopsIntersections ( loop , loopsLoopsIntersections , otherLoops ) : for pointIndex in xrange ( len ( loop ) ) : pointBegin = loop [ pointIndex ] pointEnd = loop [ ( ( pointIndex + 1 ) % len ( loop ) ) ] addLineLoopsIntersections ( loopsLoopsIntersections , otherLoops , pointBegin , pointEnd )
add intersections of the loop with the other loops .