def intersect(self, other_seg, tol=None):
if isinstance(other_seg, Line):<EOL><INDENT>assert other_seg.end != other_seg.start and self.end != self.start<EOL>assert self != other_seg<EOL>a = (self.start.real, self.end.real)<EOL>b = (self.start.imag, self.end.imag)<EOL>c = (other_seg.start.real, other_seg.end.real)<EOL>d = (other_seg.start.imag, other_seg.end.imag)<EOL>denom = ((a[<NUM_LIT:1>] - a[<NUM_LIT:0>])*(d[<NUM_LIT:0>] - d[<NUM_LIT:1>]) -<EOL>(b[<NUM_LIT:1>] - b[<NUM_LIT:0>])*(c[<NUM_LIT:0>] - c[<NUM_LIT:1>]))<EOL>if np.isclose(denom, <NUM_LIT:0>):<EOL><INDENT>return []<EOL><DEDENT>t1 = (c[<NUM_LIT:0>]*(b[<NUM_LIT:0>] - d[<NUM_LIT:1>]) -<EOL>c[<NUM_LIT:1>]*(b[<NUM_LIT:0>] - d[<NUM_LIT:0>]) -<EOL>a[<NUM_LIT:0>]*(d[<NUM_LIT:0>] - d[<NUM_LIT:1>]))/denom<EOL>t2 = -(a[<NUM_LIT:1>]*(b[<NUM_LIT:0>] - d[<NUM_LIT:0>]) -<EOL>a[<NUM_LIT:0>]*(b[<NUM_LIT:1>] - d[<NUM_LIT:0>]) -<EOL>c[<NUM_LIT:0>]*(b[<NUM_LIT:0>] - b[<NUM_LIT:1>]))/denom<EOL>if <NUM_LIT:0> <= t1 <= <NUM_LIT:1> and <NUM_LIT:0> <= t2 <= <NUM_LIT:1>:<EOL><INDENT>return [(t1, t2)]<EOL><DEDENT>return []<EOL><DEDENT>elif isinstance(other_seg, QuadraticBezier):<EOL><INDENT>t2t1s = bezier_by_line_intersections(other_seg, self)<EOL>return [(t1, t2) for t2, t1 in t2t1s]<EOL><DEDENT>elif isinstance(other_seg, CubicBezier):<EOL><INDENT>t2t1s = bezier_by_line_intersections(other_seg, self)<EOL>return [(t1, t2) for t2, t1 in t2t1s]<EOL><DEDENT>elif isinstance(other_seg, Arc):<EOL><INDENT>t2t1s = other_seg.intersect(self)<EOL>return [(t1, t2) for t2, t1 in t2t1s]<EOL><DEDENT>elif isinstance(other_seg, Path):<EOL><INDENT>raise TypeError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>
Finds the intersections of two segments.
        returns a list of tuples (t1, t2) such that
        self.point(t1) == other_seg.point(t2).
        Note: This will fail if the two segments coincide for more than a
        finite collection of points.
        tol is not used.