def intersect(self, other_curve, justonemode=False, tol=<NUM_LIT>):
path1 = self<EOL>if isinstance(other_curve, Path):<EOL><INDENT>path2 = other_curve<EOL><DEDENT>else:<EOL><INDENT>path2 = Path(other_curve)<EOL><DEDENT>assert path1 != path2<EOL>intersection_list = []<EOL>for seg1 in path1:<EOL><INDENT>for seg2 in path2:<EOL><INDENT>if justonemode and intersection_list:<EOL><INDENT>return intersection_list[<NUM_LIT:0>]<EOL><DEDENT>for t1, t2 in seg1.intersect(seg2, tol=tol):<EOL><INDENT>T1 = path1.t2T(seg1, t1)<EOL>T2 = path2.t2T(seg2, t2)<EOL>intersection_list.append(((T1, seg1, t1), (T2, seg2, t2)))<EOL><DEDENT><DEDENT><DEDENT>if justonemode and intersection_list:<EOL><INDENT>return intersection_list[<NUM_LIT:0>]<EOL><DEDENT>if intersection_list:<EOL><INDENT>pts = [seg1.point(_t1)<EOL>for _T1, _seg1, _t1 in list(zip(*intersection_list))[<NUM_LIT:0>]]<EOL>indices2remove = []<EOL>for ind1 in range(len(pts)):<EOL><INDENT>for ind2 in range(ind1 + <NUM_LIT:1>, len(pts)):<EOL><INDENT>if abs(pts[ind1] - pts[ind2]) < tol:<EOL><INDENT>indices2remove.append(ind2)<EOL><DEDENT><DEDENT><DEDENT>intersection_list = [inter for ind, inter in<EOL>enumerate(intersection_list) if<EOL>ind not in indices2remove]<EOL><DEDENT>return intersection_list<EOL>
returns list of pairs of pairs ((T1, seg1, t1), (T2, seg2, t2))
        giving the intersection points.
        If justonemode==True, then returns just the first
        intersection found.
        tol is used to check for redundant intersections (see comment above
        the code block where tol is used).
        Note:  If the two path objects coincide for more than a finite set of
        points, this code will fail.