(self, o)
return [r for r in result if r in o]
Find the intersection of a LinearEntity and the ellipse.

        All LinearEntities are treated as a line and filtered at
        the end to see that they lie in o.
Find the intersection of a LinearEntity and the ellipse.
Find the intersection of a LinearEntity and the ellipse .
def _do_line_intersection(self, o):
        """
        Find the intersection of a LinearEntity and the ellipse.

        All LinearEntities are treated as a line and filtered at
        the end to see that they lie in o.

        """

        hr_sq = self.hradius ** 2
        vr_sq = self.vradius ** 2
        lp = o.points

        ldir = lp[1] - lp[0]
        diff = lp[0] - self.center
        mdir = Point(ldir.x/hr_sq, ldir.y/vr_sq)
        mdiff = Point(diff.x/hr_sq, diff.y/vr_sq)

        a = ldir.dot(mdir)
        b = ldir.dot(mdiff)
        c = diff.dot(mdiff) - 1
        det = simplify(b*b - a*c)

        result = []
        if det == 0:
            t = -b / a
            result.append(lp[0] + (lp[1] - lp[0]) * t)
        else:
            is_good = True
            try:
                is_good = (det > 0)
            except NotImplementedError:  # symbolic, allow
                is_good = True

            if is_good:
                root = sqrt(det)
                t_a = (-b - root) / a
                t_b = (-b + root) / a
                result.append( lp[0] + (lp[1] - lp[0]) * t_a )
                result.append( lp[0] + (lp[1] - lp[0]) * t_b )

        return [r for r in result if r in o]
def _do_line_intersection ( self , o ) : hr_sq = self . hradius ** 2 vr_sq = self . vradius ** 2 lp = o . points ldir = lp [ 1 ] - lp [ 0 ] diff = lp [ 0 ] - self . center mdir = Point ( ldir . x / hr_sq , ldir . y / vr_sq ) mdiff = Point ( diff . x / hr_sq , diff . y / vr_sq ) a = ldir . dot ( mdir ) b = ldir . dot ( mdiff ) c = diff . dot ( mdiff ) - 1 det = simplify ( b * b - a * c ) result = [ ] if det == 0 : t = - b / a result . append ( lp [ 0 ] + ( lp [ 1 ] - lp [ 0 ] ) * t ) else : is_good = True try : is_good = ( det > 0 ) except NotImplementedError : # symbolic, allow is_good = True if is_good : root = sqrt ( det ) t_a = ( - b - root ) / a t_b = ( - b + root ) / a result . append ( lp [ 0 ] + ( lp [ 1 ] - lp [ 0 ] ) * t_a ) result . append ( lp [ 0 ] + ( lp [ 1 ] - lp [ 0 ] ) * t_b ) return [ r for r in result if r in o ]