<s> """<STR_LIT>""" <EOL> from __future__ import division , print_function <EOL> from sympy . core import S , pi , sympify <EOL> from sympy . core . logic import fuzzy_bool <EOL> from sympy . core . numbers import Rational , oo <EOL> from sympy . core . compatibility import range <EOL> from sympy . core . symbol import Dummy <EOL> from sympy . simplify import simplify , trigsimp <EOL> from sympy . functions . elementary . miscellaneous import sqrt <EOL> from sympy . functions . elementary . trigonometric import cos , sin <EOL> from sympy . geometry . exceptions import GeometryError <EOL> from sympy . polys import DomainError , Poly , PolynomialError <EOL> from sympy . polys . polyutils import _not_a_coeff , _nsort <EOL> from sympy . solvers import solve <EOL> from sympy . utilities . iterables import uniq <EOL> from sympy . utilities . misc import filldedent <EOL> from sympy . utilities . decorator import doctest_depends_on <EOL> from . entity import GeometryEntity , GeometrySet <EOL> from . point import Point <EOL> from . line import Line , LinearEntity <EOL> from . util import _symbol , idiff <EOL> import random <EOL> class Ellipse ( GeometrySet ) : <EOL> """<STR_LIT>""" <EOL> def __new__ ( <EOL> cls , center = None , hradius = None , vradius = None , eccentricity = None , <EOL> ** kwargs ) : <EOL> hradius = sympify ( hradius ) <EOL> vradius = sympify ( vradius ) <EOL> eccentricity = sympify ( eccentricity ) <EOL> if center is None : <EOL> center = Point ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> else : <EOL> center = Point ( center ) <EOL> if len ( center ) != <NUM_LIT:2> : <EOL> raise ValueError ( '<STR_LIT>' . format ( cls ) ) <EOL> if len ( list ( filter ( None , ( hradius , vradius , eccentricity ) ) ) ) != <NUM_LIT:2> : <EOL> raise ValueError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> if eccentricity is not None : <EOL> if hradius is None : <EOL> hradius = vradius / sqrt ( <NUM_LIT:1> - eccentricity ** <NUM_LIT:2> ) <EOL> elif vradius is None : <EOL> vradius = hradius * sqrt ( <NUM_LIT:1> - eccentricity ** <NUM_LIT:2> ) <EOL> if hradius == vradius : <EOL> return Circle ( center , hradius , ** kwargs ) <EOL> return GeometryEntity . __new__ ( cls , center , hradius , vradius , ** kwargs ) <EOL> @ property <EOL> def ambient_dimension ( self ) : <EOL> return <NUM_LIT:2> <EOL> @ property <EOL> def center ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . args [ <NUM_LIT:0> ] <EOL> @ property <EOL> def hradius ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . args [ <NUM_LIT:1> ] <EOL> @ property <EOL> def vradius ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . args [ <NUM_LIT:2> ] <EOL> @ property <EOL> def minor ( self ) : <EOL> """<STR_LIT>""" <EOL> ab = self . args [ <NUM_LIT:1> : <NUM_LIT:3> ] <EOL> if len ( ab ) == <NUM_LIT:1> : <EOL> return ab [ <NUM_LIT:0> ] <EOL> a , b = ab <EOL> o = a - b < <NUM_LIT:0> <EOL> if o == True : <EOL> return a <EOL> elif o == False : <EOL> return b <EOL> return self . vradius <EOL> @ property <EOL> def major ( self ) : <EOL> """<STR_LIT>""" <EOL> ab = self . args [ <NUM_LIT:1> : <NUM_LIT:3> ] <EOL> if len ( ab ) == <NUM_LIT:1> : <EOL> return ab [ <NUM_LIT:0> ] <EOL> a , b = ab <EOL> o = b - a < <NUM_LIT:0> <EOL> if o == True : <EOL> return a <EOL> elif o == False : <EOL> return b <EOL> return self . hradius <EOL> @ property <EOL> def area ( self ) : <EOL> """<STR_LIT>""" <EOL> return simplify ( S . Pi * self . hradius * self . vradius ) <EOL> @ property <EOL> def circumference ( self ) : <EOL> """<STR_LIT>""" <EOL> from sympy import Integral <EOL> if self . eccentricity == <NUM_LIT:1> : <EOL> return <NUM_LIT:2> * pi * self . hradius <EOL> else : <EOL> x = Dummy ( '<STR_LIT:x>' , real = True ) <EOL> return <NUM_LIT:4> * self . major * Integral ( <EOL> sqrt ( ( <NUM_LIT:1> - ( self . eccentricity * x ) ** <NUM_LIT:2> ) / ( <NUM_LIT:1> - x ** <NUM_LIT:2> ) ) , ( x , <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> @ property <EOL> def eccentricity ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . focus_distance / self . major <EOL> @ property <EOL> def periapsis ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . major * ( <NUM_LIT:1> - self . eccentricity ) <EOL> @ property <EOL> def apoapsis ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . major * ( <NUM_LIT:1> + self . eccentricity ) <EOL> @ property <EOL> def focus_distance ( self ) : <EOL> """<STR_LIT>""" <EOL> return Point . distance ( self . center , self . foci [ <NUM_LIT:0> ] ) <EOL> @ property <EOL> def foci ( self ) : <EOL> """<STR_LIT>""" <EOL> c = self . center <EOL> hr , vr = self . hradius , self . vradius <EOL> if hr == vr : <EOL> return ( c , c ) <EOL> fd = sqrt ( self . major ** <NUM_LIT:2> - self . minor ** <NUM_LIT:2> ) <EOL> if hr == self . minor : <EOL> return ( c + Point ( <NUM_LIT:0> , - fd ) , c + Point ( <NUM_LIT:0> , fd ) ) <EOL> elif hr == self . major : <EOL> return ( c + Point ( - fd , <NUM_LIT:0> ) , c + Point ( fd , <NUM_LIT:0> ) ) <EOL> @ property <EOL> def bounds ( self ) : <EOL> """<STR_LIT>""" <EOL> h , v = self . hradius , self . vradius <EOL> return ( self . center . x - h , self . center . y - v , self . center . x + h , self . center . y + v ) <EOL> def rotate ( self , angle = <NUM_LIT:0> , pt = None ) : <EOL> """<STR_LIT>""" <EOL> if self . hradius == self . vradius : <EOL> return self . func ( * self . args ) <EOL> if ( angle / S . Pi ) . is_integer : <EOL> return super ( Ellipse , self ) . rotate ( angle , pt ) <EOL> if ( <NUM_LIT:2> * angle / S . Pi ) . is_integer : <EOL> return self . func ( self . center . rotate ( angle , pt ) , self . vradius , self . hradius ) <EOL> raise NotImplementedError ( '<STR_LIT>' ) <EOL> def scale ( self , x = <NUM_LIT:1> , y = <NUM_LIT:1> , pt = None ) : <EOL> """<STR_LIT>""" <EOL> c = self . center <EOL> if pt : <EOL> pt = Point ( pt ) <EOL> return self . translate ( * ( - pt ) . args ) . scale ( x , y ) . translate ( * pt . args ) <EOL> h = self . hradius <EOL> v = self . vradius <EOL> return self . func ( c . scale ( x , y ) , hradius = h * x , vradius = v * y ) <EOL> def reflect ( self , line ) : <EOL> """<STR_LIT>""" <EOL> from . util import _uniquely_named_symbol <EOL> if line . slope in ( <NUM_LIT:0> , oo ) : <EOL> c = self . center <EOL> c = c . reflect ( line ) <EOL> return self . func ( c , - self . hradius , self . vradius ) <EOL> else : <EOL> x , y = [ _uniquely_named_symbol ( name , self , line ) for name in '<STR_LIT>' ] <EOL> expr = self . equation ( x , y ) <EOL> p = Point ( x , y ) . reflect ( line ) <EOL> result = expr . subs ( zip ( ( x , y ) , p . args <EOL> ) , simultaneous = True ) <EOL> raise NotImplementedError ( filldedent ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' + <EOL> "<STR_LIT>" % ( str ( x ) , str ( y ) , str ( result ) ) ) ) <EOL> def encloses_point ( self , p ) : <EOL> """<STR_LIT>""" <EOL> p = Point ( p ) <EOL> if p in self : <EOL> return False <EOL> if len ( self . foci ) == <NUM_LIT:2> : <EOL> h1 , h2 = [ f . distance ( p ) for f in self . foci ] <EOL> test = <NUM_LIT:2> * self . major - ( h1 + h2 ) <EOL> else : <EOL> test = self . radius - self . center . distance ( p ) <EOL> return fuzzy_bool ( test . is_positive ) <EOL> @ doctest_depends_on ( modules = ( '<STR_LIT>' , ) ) <EOL> def tangent_lines ( self , p ) : <EOL> """<STR_LIT>""" <EOL> p = Point ( p ) <EOL> if self . encloses_point ( p ) : <EOL> return [ ] <EOL> if p in self : <EOL> delta = self . center - p <EOL> rise = ( self . vradius ** <NUM_LIT:2> ) * delta . x <EOL> run = - ( self . hradius ** <NUM_LIT:2> ) * delta . y <EOL> p2 = Point ( simplify ( p . x + run ) , <EOL> simplify ( p . y + rise ) ) <EOL> return [ Line ( p , p2 ) ] <EOL> else : <EOL> if len ( self . foci ) == <NUM_LIT:2> : <EOL> f1 , f2 = self . foci <EOL> maj = self . hradius <EOL> test = ( <NUM_LIT:2> * maj - <EOL> Point . distance ( f1 , p ) - <EOL> Point . distance ( f2 , p ) ) <EOL> else : <EOL> test = self . radius - Point . distance ( self . center , p ) <EOL> if test . is_number and test . is_positive : <EOL> return [ ] <EOL> x , y = Dummy ( '<STR_LIT:x>' ) , Dummy ( '<STR_LIT:y>' ) <EOL> eq = self . equation ( x , y ) <EOL> dydx = idiff ( eq , y , x ) <EOL> slope = Line ( p , Point ( x , y ) ) . slope <EOL> tangent_points = solve ( [ slope - dydx , eq ] , [ x , y ] ) <EOL> if len ( tangent_points ) == <NUM_LIT:1> : <EOL> assert tangent_points [ <NUM_LIT:0> ] [ <EOL> <NUM_LIT:0> ] == p . x or tangent_points [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] == p . y <EOL> return [ Line ( p , p + Point ( <NUM_LIT:1> , <NUM_LIT:0> ) ) , Line ( p , p + Point ( <NUM_LIT:0> , <NUM_LIT:1> ) ) ] <EOL> return [ Line ( p , tangent_points [ <NUM_LIT:0> ] ) , Line ( p , tangent_points [ <NUM_LIT:1> ] ) ] <EOL> def is_tangent ( self , o ) : <EOL> """<STR_LIT>""" <EOL> inter = None <EOL> if isinstance ( o , Ellipse ) : <EOL> inter = self . intersection ( o ) <EOL> if isinstance ( inter , Ellipse ) : <EOL> return False <EOL> return ( inter is not None and len ( inter ) == <NUM_LIT:1> <EOL> and isinstance ( inter [ <NUM_LIT:0> ] , Point ) ) <EOL> elif isinstance ( o , LinearEntity ) : <EOL> inter = self . _do_line_intersection ( o ) <EOL> if inter is not None and len ( inter ) == <NUM_LIT:1> : <EOL> return inter [ <NUM_LIT:0> ] in o <EOL> else : <EOL> return False <EOL> elif isinstance ( o , Polygon ) : <EOL> c = <NUM_LIT:0> <EOL> for seg in o . sides : <EOL> inter = self . _do_line_intersection ( seg ) <EOL> c += len ( [ True for point in inter if point in seg ] ) <EOL> return c == <NUM_LIT:1> <EOL> else : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def normal_lines ( self , p , prec = None ) : <EOL> """<STR_LIT>""" <EOL> p = Point ( p ) <EOL> if True : <EOL> rv = [ ] <EOL> if p . x == self . center . x : <EOL> rv . append ( Line ( self . center , slope = oo ) ) <EOL> if p . y == self . center . y : <EOL> rv . append ( Line ( self . center , slope = <NUM_LIT:0> ) ) <EOL> if rv : <EOL> return rv <EOL> x , y = Dummy ( '<STR_LIT:x>' , real = True ) , Dummy ( '<STR_LIT:y>' , real = True ) <EOL> eq = self . equation ( x , y ) <EOL> dydx = idiff ( eq , y , x ) <EOL> norm = - <NUM_LIT:1> / dydx <EOL> slope = Line ( p , ( x , y ) ) . slope <EOL> seq = slope - norm <EOL> yis = solve ( seq , y ) [ <NUM_LIT:0> ] <EOL> xeq = eq . subs ( y , yis ) . as_numer_denom ( ) [ <NUM_LIT:0> ] . expand ( ) <EOL> if len ( xeq . free_symbols ) == <NUM_LIT:1> : <EOL> try : <EOL> xsol = Poly ( xeq , x ) . real_roots ( ) <EOL> except ( DomainError , PolynomialError , NotImplementedError ) : <EOL> xsol = _nsort ( solve ( xeq , x ) , separated = True ) [ <NUM_LIT:0> ] <EOL> points = [ Point ( i , solve ( eq . subs ( x , i ) , y ) [ <NUM_LIT:0> ] ) for i in xsol ] <EOL> else : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> slopes = [ norm . subs ( zip ( ( x , y ) , pt . args ) ) for pt in points ] <EOL> if prec is not None : <EOL> points = [ pt . n ( prec ) for pt in points ] <EOL> slopes = [ i if _not_a_coeff ( i ) else i . n ( prec ) for i in slopes ] <EOL> return [ Line ( pt , slope = s ) for pt , s in zip ( points , slopes ) ] <EOL> def arbitrary_point ( self , parameter = '<STR_LIT:t>' ) : <EOL> """<STR_LIT>""" <EOL> t = _symbol ( parameter ) <EOL> if t . name in ( f . name for f in self . free_symbols ) : <EOL> raise ValueError ( filldedent ( '<STR_LIT>' <EOL> '<STR_LIT>' % t . name ) ) <EOL> return Point ( self . center . x + self . hradius * cos ( t ) , <EOL> self . center . y + self . vradius * sin ( t ) ) <EOL> def plot_interval ( self , parameter = '<STR_LIT:t>' ) : <EOL> """<STR_LIT>""" <EOL> t = _symbol ( parameter ) <EOL> return [ t , - S . Pi , S . Pi ] <EOL> def random_point ( self , seed = None ) : <EOL> """<STR_LIT>""" <EOL> from sympy import sin , cos , Rational <EOL> t = _symbol ( '<STR_LIT:t>' ) <EOL> x , y = self . arbitrary_point ( t ) . args <EOL> if seed is not None : <EOL> rng = random . Random ( seed ) <EOL> else : <EOL> rng = random <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> c = <NUM_LIT:2> * Rational ( rng . random ( ) ) - <NUM_LIT:1> <EOL> s = sqrt ( <NUM_LIT:1> - c ** <NUM_LIT:2> ) <EOL> p1 = Point ( x . subs ( cos ( t ) , c ) , y . subs ( sin ( t ) , s ) ) <EOL> if p1 in self : <EOL> return p1 <EOL> raise GeometryError ( <EOL> '<STR_LIT>' ) <EOL> def equation ( self , x = '<STR_LIT:x>' , y = '<STR_LIT:y>' ) : <EOL> """<STR_LIT>""" <EOL> x = _symbol ( x ) <EOL> y = _symbol ( y ) <EOL> t1 = ( ( x - self . center . x ) / self . hradius ) ** <NUM_LIT:2> <EOL> t2 = ( ( y - self . center . y ) / self . vradius ) ** <NUM_LIT:2> <EOL> return t1 + t2 - <NUM_LIT:1> <EOL> def _do_line_intersection ( self , o ) : <EOL> """<STR_LIT>""" <EOL> hr_sq = self . hradius ** <NUM_LIT:2> <EOL> vr_sq = self . vradius ** <NUM_LIT:2> <EOL> lp = o . points <EOL> ldir = lp [ <NUM_LIT:1> ] - lp [ <NUM_LIT:0> ] <EOL> diff = lp [ <NUM_LIT:0> ] - self . center <EOL> mdir = Point ( ldir . x / hr_sq , ldir . y / vr_sq ) <EOL> mdiff = Point ( diff . x / hr_sq , diff . y / vr_sq ) <EOL> a = ldir . dot ( mdir ) <EOL> b = ldir . dot ( mdiff ) <EOL> c = diff . dot ( mdiff ) - <NUM_LIT:1> <EOL> det = simplify ( b * b - a * c ) <EOL> result = [ ] <EOL> if det == <NUM_LIT:0> : <EOL> t = - b / a <EOL> result . append ( lp [ <NUM_LIT:0> ] + ( lp [ <NUM_LIT:1> ] - lp [ <NUM_LIT:0> ] ) * t ) <EOL> elif ( det > <NUM_LIT:0> ) != False : <EOL> root = sqrt ( det ) <EOL> t_a = ( - b - root ) / a <EOL> t_b = ( - b + root ) / a <EOL> result . append ( lp [ <NUM_LIT:0> ] + ( lp [ <NUM_LIT:1> ] - lp [ <NUM_LIT:0> ] ) * t_a ) <EOL> result . append ( lp [ <NUM_LIT:0> ] + ( lp [ <NUM_LIT:1> ] - lp [ <NUM_LIT:0> ] ) * t_b ) <EOL> return [ r for r in result if r in o ] <EOL> def _do_ellipse_intersection ( self , o ) : <EOL> """<STR_LIT>""" <EOL> x = Dummy ( '<STR_LIT:x>' , real = True ) <EOL> y = Dummy ( '<STR_LIT:y>' , real = True ) <EOL> seq = self . equation ( x , y ) <EOL> oeq = o . equation ( x , y ) <EOL> result = solve ( [ seq , oeq ] , [ x , y ] ) <EOL> return [ Point ( * r ) for r in list ( uniq ( result ) ) ] <EOL> def intersection ( self , o ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( o , Point ) : <EOL> if o in self : <EOL> return [ o ] <EOL> else : <EOL> return [ ] <EOL> elif isinstance ( o , LinearEntity ) : <EOL> return self . _do_line_intersection ( o ) <EOL> elif isinstance ( o , Circle ) : <EOL> return self . _do_ellipse_intersection ( o ) <EOL> elif isinstance ( o , Ellipse ) : <EOL> if o == self : <EOL> return self <EOL> else : <EOL> return self . _do_ellipse_intersection ( o ) <EOL> return o . intersection ( self ) <EOL> def evolute ( self , x = '<STR_LIT:x>' , y = '<STR_LIT:y>' ) : <EOL> """<STR_LIT>""" <EOL> if len ( self . args ) != <NUM_LIT:3> : <EOL> raise NotImplementedError ( '<STR_LIT>' ) <EOL> x = _symbol ( x ) <EOL> y = _symbol ( y ) <EOL> t1 = ( self . hradius * ( x - self . center . x ) ) ** Rational ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> t2 = ( self . vradius * ( y - self . center . y ) ) ** Rational ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> return t1 + t2 - ( self . hradius ** <NUM_LIT:2> - self . vradius ** <NUM_LIT:2> ) ** Rational ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> def __eq__ ( self , o ) : <EOL> """<STR_LIT>""" <EOL> return isinstance ( o , GeometryEntity ) and ( self . center == o . center and <EOL> self . hradius == o . hradius and <EOL> self . vradius == o . vradius ) <EOL> def __hash__ ( self ) : <EOL> return super ( Ellipse , self ) . __hash__ ( ) <EOL> def __contains__ ( self , o ) : <EOL> if isinstance ( o , Point ) : <EOL> x = Dummy ( '<STR_LIT:x>' , real = True ) <EOL> y = Dummy ( '<STR_LIT:y>' , real = True ) <EOL> res = self . equation ( x , y ) . subs ( { x : o . x , y : o . y } ) <EOL> return trigsimp ( simplify ( res ) ) is S . Zero <EOL> elif isinstance ( o , Ellipse ) : <EOL> return self == o <EOL> return False <EOL> def _svg ( self , scale_factor = <NUM_LIT:1.> , fill_color = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> from sympy . core . evalf import N <EOL> c = N ( self . center ) <EOL> h , v = N ( self . hradius ) , N ( self . vradius ) <EOL> return ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) . format ( <NUM_LIT> * scale_factor , fill_color , c . x , c . y , h , v ) <EOL> class Circle ( Ellipse ) : <EOL> """<STR_LIT>""" <EOL> def __new__ ( cls , * args , ** kwargs ) : <EOL> c , r = None , None <EOL> if len ( args ) == <NUM_LIT:3> : <EOL> args = [ Point ( a ) for a in args ] <EOL> if Point . is_collinear ( * args ) : <EOL> raise GeometryError ( <EOL> "<STR_LIT>" ) <EOL> from . polygon import Triangle <EOL> t = Triangle ( * args ) <EOL> c = t . circumcenter <EOL> r = t . circumradius <EOL> elif len ( args ) == <NUM_LIT:2> : <EOL> c = Point ( args [ <NUM_LIT:0> ] ) <EOL> r = sympify ( args [ <NUM_LIT:1> ] ) <EOL> if not ( c is None or r is None ) : <EOL> return GeometryEntity . __new__ ( cls , c , r , ** kwargs ) <EOL> raise GeometryError ( "<STR_LIT>" ) <EOL> @ property <EOL> def radius ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . args [ <NUM_LIT:1> ] <EOL> @ property <EOL> def vradius ( self ) : <EOL> """<STR_LIT>""" <EOL> return abs ( self . radius ) <EOL> @ property <EOL> def circumference ( self ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:2> * S . Pi * self . radius <EOL> def equation ( self , x = '<STR_LIT:x>' , y = '<STR_LIT:y>' ) : <EOL> """<STR_LIT>""" <EOL> x = _symbol ( x ) <EOL> y = _symbol ( y ) <EOL> t1 = ( x - self . center . x ) ** <NUM_LIT:2> <EOL> t2 = ( y - self . center . y ) ** <NUM_LIT:2> <EOL> return t1 + t2 - self . major ** <NUM_LIT:2> <EOL> def intersection ( self , o ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( o , Circle ) : <EOL> if o . center == self . center : <EOL> if o . radius == self . radius : <EOL> return o <EOL> return [ ] <EOL> dx , dy = ( o . center - self . center ) . args <EOL> d = sqrt ( simplify ( dy ** <NUM_LIT:2> + dx ** <NUM_LIT:2> ) ) <EOL> R = o . radius + self . radius <EOL> if d > R or d < abs ( self . radius - o . radius ) : <EOL> return [ ] <EOL> a = simplify ( ( self . radius ** <NUM_LIT:2> - o . radius ** <NUM_LIT:2> + d ** <NUM_LIT:2> ) / ( <NUM_LIT:2> * d ) ) <EOL> x2 = self . center . x + ( dx * a / d ) <EOL> y2 = self . center . y + ( dy * a / d ) <EOL> h = sqrt ( simplify ( self . radius ** <NUM_LIT:2> - a ** <NUM_LIT:2> ) ) <EOL> rx = - dy * ( h / d ) <EOL> ry = dx * ( h / d ) <EOL> xi_1 = simplify ( x2 + rx ) <EOL> xi_2 = simplify ( x2 - rx ) <EOL> yi_1 = simplify ( y2 + ry ) <EOL> yi_2 = simplify ( y2 - ry ) <EOL> ret = [ Point ( xi_1 , yi_1 ) ] <EOL> if xi_1 != xi_2 or yi_1 != yi_2 : <EOL> ret . append ( Point ( xi_2 , yi_2 ) ) <EOL> return ret <EOL> return Ellipse . intersection ( self , o ) <EOL> def scale ( self , x = <NUM_LIT:1> , y = <NUM_LIT:1> , pt = None ) : <EOL> """<STR_LIT>""" <EOL> c = self . center <EOL> if pt : <EOL> pt = Point ( pt ) <EOL> return self . translate ( * ( - pt ) . args ) . scale ( x , y ) . translate ( * pt . args ) <EOL> c = c . scale ( x , y ) <EOL> x , y = [ abs ( i ) for i in ( x , y ) ] <EOL> if x == y : <EOL> return self . func ( c , x * self . radius ) <EOL> h = v = self . radius <EOL> return Ellipse ( c , hradius = h * x , vradius = v * y ) <EOL> def reflect ( self , line ) : <EOL> """<STR_LIT>""" <EOL> c = self . center <EOL> c = c . reflect ( line ) <EOL> return self . func ( c , - self . radius ) <EOL> from . polygon import Polygon </s>
