parameters: (polygon1, polygon2)
return_statement: return ret
docstring: Returns the 2D-length from polygon1's start to all intersections between polygon1 and polygon2.
docstring_summary: Returns the 2D-length from polygon1's start to all intersections between polygon1 and polygon2.
docstring_tokens: Returns the 2D - length from polygon1 s start to all intersections between polygon1 and polygon2 .
function: def intersectsAtLengths2D(polygon1, polygon2):
      """
      Returns the 2D-length from polygon1's start to all intersections between polygon1 and polygon2.
      """
      ret = []
      if (len(polygon1) == 0 or len(polygon2) == 0):
          return ret
      polygon1Length = polyLength(polygon1)
      for j in range(len(polygon2) - 1):
          p21 = polygon2[j]
          p22 = polygon2[j + 1]
          pos = 0.0
          for i in range(len(polygon1) - 1):
              p11 = polygon1[i]
              p12 = polygon1[i + 1]
              pIntersection = [0.0, 0.0]
              if (intersectsLineSegment(p11, p12, p21, p22, 0.0, pIntersection, True)):
                  for k in range(0, len(pIntersection), 2):
                      length = pos + distance(p11, (pIntersection[k], pIntersection[k + 1]))
                      # special case for closed polygons
                      if isClosedPolygon(polygon1) and isclose(length, polygon1Length):
                          length = 0.0
                      # check for duplicate
                      isDuplicate = False
                      for result in ret:
                          if isclose(length, result):
                              isDuplicate = True
                              break
                      if not isDuplicate:
                          ret.append(length)
              pos += distance(p11, p12)
      return ret
function_tokens: def intersectsAtLengths2D ( polygon1 , polygon2 ) : ret = [ ] if ( len ( polygon1 ) == 0 or len ( polygon2 ) == 0 ) : return ret polygon1Length = polyLength ( polygon1 ) for j in range ( len ( polygon2 ) - 1 ) : p21 = polygon2 [ j ] p22 = polygon2 [ j + 1 ] pos = 0.0 for i in range ( len ( polygon1 ) - 1 ) : p11 = polygon1 [ i ] p12 = polygon1 [ i + 1 ] pIntersection = [ 0.0 , 0.0 ] if ( intersectsLineSegment ( p11 , p12 , p21 , p22 , 0.0 , pIntersection , True ) ) : for k in range ( 0 , len ( pIntersection ) , 2 ) : length = pos + distance ( p11 , ( pIntersection [ k ] , pIntersection [ k + 1 ] ) ) # special case for closed polygons if isClosedPolygon ( polygon1 ) and isclose ( length , polygon1Length ) : length = 0.0 # check for duplicate isDuplicate = False for result in ret : if isclose ( length , result ) : isDuplicate = True break if not isDuplicate : ret . append ( length ) pos += distance ( p11 , p12 ) return ret