
    wgW                        d Z ddlmZ ddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZmZmZ ddlmZmZ ddlmZmZ ddlmZm Z  ddl!m"Z" ddl#m$Z$m%Z% ddl&m'Z' ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9 ddl:m;Z;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZBmCZC ddlDmEZE ddlFZF eGd      D  cg c]  }  edd       c} \  ZHZI G d  d!e%      ZJ G d" d#eJ      ZKdd$lLmMZMmNZN yc c} w )%z?Elliptical geometrical entities.

Contains
* Ellipse
* Circle

    )Expr)Eq)Spisympify)N)global_parameters)
fuzzy_bool)Rationaloo)ordered)Dummyuniquely_named_symbol_symbol)simplifytrigsimp)sqrtMax)cossin)
elliptic_e   )GeometryEntityGeometrySet)GeometryError)LineSegmentRay2D	Segment2DLine2DLinearEntity3D)PointPoint2DPoint3D)idifffind)DomainErrorPolyPolynomialError)_not_a_coeff_nsort)solve)linear_coeffs)
filldedent	func_name)prec_to_dpsN   ellipse_dummyTrealc                       e Zd ZdZd Zd Z fdZ	 d(dZd)dZe	d        Z
e	d        Zd*d	Ze	d
        Ze	d        Ze	d        Ze	d        Ze	d        Zd Zd+dZd,dZe	d        Ze	d        Ze	d        Zd Zd Ze	d        Ze	d        Zd-dZe	d        Ze	d        Zd Zd Z d*dZ!d-dZ"d  Z#d. fd!	Z$d/d"Z%d# Z&e	d$        Z'd-d%Z(d& Z)d-d'Z* xZ+S )0Ellipsea"  An elliptical GeometryEntity.

    Parameters
    ==========

    center : Point, optional
        Default value is Point(0, 0)
    hradius : number or SymPy expression, optional
    vradius : number or SymPy expression, optional
    eccentricity : number or SymPy expression, optional
        Two of `hradius`, `vradius` and `eccentricity` must be supplied to
        create an Ellipse. The third is derived from the two supplied.

    Attributes
    ==========

    center
    hradius
    vradius
    area
    circumference
    eccentricity
    periapsis
    apoapsis
    focus_distance
    foci

    Raises
    ======

    GeometryError
        When `hradius`, `vradius` and `eccentricity` are incorrectly supplied
        as parameters.
    TypeError
        When `center` is not a Point.

    See Also
    ========

    Circle

    Notes
    -----
    Constructed from a center and two radii, the first being the horizontal
    radius (along the x-axis) and the second being the vertical radius (along
    the y-axis).

    When symbolic value for hradius and vradius are used, any calculation that
    refers to the foci or the major or minor axis will assume that the ellipse
    has its major radius on the x-axis. If this is not true then a manual
    rotation is necessary.

    Examples
    ========

    >>> from sympy import Ellipse, Point, Rational
    >>> e1 = Ellipse(Point(0, 0), 5, 1)
    >>> e1.hradius, e1.vradius
    (5, 1)
    >>> e2 = Ellipse(Point(3, 1), hradius=3, eccentricity=Rational(4, 5))
    >>> e2
    Ellipse(Point2D(3, 1), 3, 9/5)

    c                 (   t        |t              rm| j                  t        t              j                  t        |j                  t        |j                  i      }t        t        |            t        j                  u S t        |t              r| |k(  S y)NF)
isinstancer"   equationxysubsr   r   r   Zeror6   )selforess      [/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/geometry/ellipse.py__contains__zEllipse.__contains__j   sg    a--1%**AqssAqss+;<CHSM*aff447#19    c                     t        |t              xrO | j                  |j                  k(  xr4 | j                  |j                  k(  xr | j                  |j                  k(  S )z5Is the other GeometryEntity the same as this ellipse?)r8   r6   centerhradiusvradiusr>   r?   s     rA   __eq__zEllipse.__eq__r   sS    !W% F4;;!((+B ,E+/<<199+D,E+/<<199+D	FrC   c                      t         |          S N)super__hash__)r>   	__class__s    rA   rM   zEllipse.__hash__x   s    w!!rC   c           
         t        |      }t        |      }|t        dd      }n5t        |      dk7  rt        dj	                  |             t        |d      }t        t        t        d |||f                  dk7  rt        t        d            |Ot        |      }|j                  rt        d      ||t        d|dz  z
        z  }n||t        d|dz  z
        z  }||k(  rt        ||fi |S t        j                  ||fv r8t        t        |d   |z
  |d   |z
        t        |d   |z   |d   |z               S |j                  d	u s|j                  d	u rt        d
      t!        j"                  | |||fi |S )Nr   r1   z2The center of "{}" must be a two dimensional pointdimc                 
    | d uS rK    )r:   s    rA   <lambda>z!Ellipse.__new__.<locals>.<lambda>   s
    Qd] rC   zt
                Exactly two arguments of "hradius", "vradius", and
                "eccentricity" must not be None.z8Eccentricity of ellipse/circle should lie between [0, 1)r   Fz;Invalid value encountered when computing hradius / vradius.)r   r"   len
ValueErrorformatlistfilterr.   is_negativer   r   Circler   r=   r   is_realr   __new__)clsrE   rF   rG   eccentricitykwargss         rA   r]   zEllipse.__new__{   s    '"'">1a[F6{a !U!\!\]`!abb6q)FtF2Wg|4TUVW[\\Z )4 5 6 6 #"<0L''#$^__!D\1_)<$==!D\1_)<$==g&'4V4466gw''5W!4fQi'6IJERXYZR[^eRegmnogpszgzL{||??e#w%'? ]^^%%c67GNvNNrC   c                     t        | j                        }t        | j                        t        | j                        }}dj	                  d|z  ||j
                  |j                  ||      S )a%  Returns SVG ellipse element for the Ellipse.

        Parameters
        ==========

        scale_factor : float
            Multiplication factor for the SVG stroke-width.  Default is 1.
        fill_color : str, optional
            Hex string for fill color. Default is "#66cc99".
        zk<ellipse fill="{1}" stroke="#555555" stroke-width="{0}" opacity="0.6" cx="{2}" cy="{3}" rx="{4}" ry="{5}"/>g       @)r   rE   rF   rG   rW   r:   r;   )r>   scale_factor
fill_colorchvs         rA   _svgzEllipse._svg   sW     dkkN$,,1U
&l"JQSS!Q
?	@rC   c                      y)Nr1   rS   r>   s    rA   ambient_dimensionzEllipse.ambient_dimension   s    rC   c                 :    | j                   d| j                  z   z  S )a  The apoapsis of the ellipse.

        The greatest distance between the focus and the contour.

        Returns
        =======

        apoapsis : number

        See Also
        ========

        periapsis : Returns shortest distance between foci and contour

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.apoapsis
        2*sqrt(2) + 3

        r   majorr_   ri   s    rA   apoapsiszEllipse.apoapsis       4 zzQ!2!2233rC   c                 h   t        |d      }|j                  d | j                  D        v r!t        t	        d|j                  z              t        | j                  j                  | j                  t        |      z  z   | j                  j                  | j                  t        |      z  z         S )aX  A parameterized point on the ellipse.

        Parameters
        ==========

        parameter : str, optional
            Default value is 't'.

        Returns
        =======

        arbitrary_point : Point

        Raises
        ======

        ValueError
            When `parameter` already appears in the functions.

        See Also
        ========

        sympy.geometry.point.Point

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> e1 = Ellipse(Point(0, 0), 3, 2)
        >>> e1.arbitrary_point()
        Point2D(3*cos(t), 2*sin(t))

        Tr3   c              3   4   K   | ]  }|j                     y wrK   )name).0fs     rA   	<genexpr>z*Ellipse.arbitrary_point.<locals>.<genexpr>   s     8aff8s   zFSymbol %s already appears in object and cannot be used as a parameter.)r   rr   free_symbolsrV   r.   r"   rE   r:   rF   r   r;   rG   r   r>   	parameterts      rA   arbitrary_pointzEllipse.arbitrary_point   s    D ID)668d&7&788Z )MOPvv)V W X XT[[]]T\\#a&%88[[]]T\\#a&%88: 	:rC   c                 h    t        t        j                  | j                  z  | j                  z        S )a  The area of the ellipse.

        Returns
        =======

        area : number

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.area
        3*pi

        )r   r   PirF   rG   ri   s    rA   areazEllipse.area   s%    & t||+dll:;;rC   c                     | j                   | j                  }}| j                  j                  |z
  | j                  j                  |z
  | j                  j                  |z   | j                  j                  |z   fS )zwReturn a tuple (xmin, ymin, xmax, ymax) representing the bounding
        rectangle for the geometric figure.

        )rF   rG   rE   r:   r;   )r>   re   rf   s      rA   boundszEllipse.bounds  sY     ||T\\1!4;;==1#4dkkmma6GYZIZ[[rC   c                      | j                   d   S )ab  The center of the ellipse.

        Returns
        =======

        center : number

        See Also
        ========

        sympy.geometry.point.Point

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.center
        Point2D(0, 0)

        r   argsri   s    rA   rE   zEllipse.center      0 yy|rC   c                     | j                   dk(  rd| j                  z  S | j                   dk(  rdt        z  | j                  z  S d| j                  z  t	        | j                   dz        z  S )zThe circumference of the ellipse.

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.circumference
        12*elliptic_e(8/9)

        r      r   r1   )r_   rm   r   rF   r   ri   s    rA   circumferencezEllipse.circumference6  sd     !TZZ<!#R4$$TZZ<
4+<+<a+? @@@rC   c                 4    | j                   | j                  z  S )a5  The eccentricity of the ellipse.

        Returns
        =======

        eccentricity : number

        Examples
        ========

        >>> from sympy import Point, Ellipse, sqrt
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, sqrt(2))
        >>> e1.eccentricity
        sqrt(7)/3

        )focus_distancerm   ri   s    rA   r_   zEllipse.eccentricityM  s    & ""TZZ//rC   c                 ^   t        |d      }|| v ryt        | j                        dk(  rB| j                  D cg c]  }|j                  |       c}\  }}d| j                  z  ||z   z
  }n(| j
                  | j                  j                  |      z
  }t        |j                        S c c}w )a  
        Return True if p is enclosed by (is inside of) self.

        Notes
        -----
        Being on the border of self is considered False.

        Parameters
        ==========

        p : Point

        Returns
        =======

        encloses_point : True, False or None

        See Also
        ========

        sympy.geometry.point.Point

        Examples
        ========

        >>> from sympy import Ellipse, S
        >>> from sympy.abc import t
        >>> e = Ellipse((0, 0), 3, 2)
        >>> e.encloses_point((0, 0))
        True
        >>> e.encloses_point(e.arbitrary_point(t).subs(t, S.Half))
        False
        >>> e.encloses_point((4, 0))
        False

        r1   rP   F)	r"   rU   focidistancerm   radiusrE   r
   is_positive)r>   prt   h1h2tests         rA   encloses_pointzEllipse.encloses_pointb  s    J !O9tyy>Q
 .2YY7ajjm7FBTZZ<27+D;;!5!5a!88D$**++ 8s   B*c                    t        |d      }t        |d      }|| j                  j                  z
  }|| j                  j                  z
  }|P|||z  z
  dz  }||z  |z   dz  }d|dz  z   }|| j                  dz  z  }	|| j
                  dz  z  }
||	z  ||
z  z   dz
  S || j                  z  dz  }|| j                  z  dz  }||z   dz
  S )a  
        Returns the equation of an ellipse aligned with the x and y axes;
        when slope is given, the equation returned corresponds to an ellipse
        with a major axis having that slope.

        Parameters
        ==========

        x : str, optional
            Label for the x-axis. Default value is 'x'.
        y : str, optional
            Label for the y-axis. Default value is 'y'.
        _slope : Expr, optional
                The slope of the major axis. Ignored when 'None'.

        Returns
        =======

        equation : SymPy expression

        See Also
        ========

        arbitrary_point : Returns parameterized point on ellipse

        Examples
        ========

        >>> from sympy import Point, Ellipse, pi
        >>> from sympy.abc import x, y
        >>> e1 = Ellipse(Point(1, 0), 3, 2)
        >>> eq1 = e1.equation(x, y); eq1
        y**2/4 + (x/3 - 1/3)**2 - 1
        >>> eq2 = e1.equation(x, y, _slope=1); eq2
        (-x + y + 1)**2/8 + (x + y - 1)**2/18 - 1

        A point on e1 satisfies eq1. Let's use one on the x-axis:

        >>> p1 = e1.center + Point(e1.major, 0)
        >>> assert eq1.subs(x, p1.x).subs(y, p1.y) == 0

        When rotated the same as the rotated ellipse, about the center
        point of the ellipse, it will satisfy the rotated ellipse's
        equation, too:

        >>> r1 = p1.rotate(pi/4, e1.center)
        >>> assert eq2.subs(x, r1.x).subs(y, r1.y) == 0

        References
        ==========

        .. [1] https://math.stackexchange.com/questions/108270/what-is-the-equation-of-an-ellipse-that-is-not-aligned-with-the-axis
        .. [2] https://en.wikipedia.org/wiki/Ellipse#Shifted_ellipse

        Tr3   r1   r   )r   rE   r:   r;   rm   minorrF   rG   )r>   r:   r;   _slopedxdyLlre   bat1t2s                rA   r9   zEllipse.equation  s    r AD!AD!fRi!#AR!#AFAIA$**a-A$**a-AQ319q=  T\\/A%BT\\/A%B7Q;rC   c                    t        | j                        dk7  rt        d      t        |d      }t        |d      }| j                  || j
                  j                  z
  z  t        dd      z  }| j                  || j
                  j                  z
  z  t        dd      z  }||z   | j                  dz  | j                  dz  z
  t        dd      z  z
  S )a  The equation of evolute of the ellipse.

        Parameters
        ==========

        x : str, optional
            Label for the x-axis. Default value is 'x'.
        y : str, optional
            Label for the y-axis. Default value is 'y'.

        Returns
        =======

        equation : SymPy expression

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> e1 = Ellipse(Point(1, 0), 3, 2)
        >>> e1.evolute()
        2**(2/3)*y**(2/3) + (3*x - 3)**(2/3) - 5**(2/3)
           z.Evolute of arbitrary Ellipse is not supported.Tr3   r1   )
rU   r   NotImplementedErrorr   rF   rE   r:   r   rG   r;   r>   r:   r;   r   r   s        rA   evolutezEllipse.evolute  s    0 tyy>Q%&VWWAD!AD!llA-.!Q?llA-.!Q?Bw$,,/DLL!O;hq!nLLLrC   c                 f   | j                   }| j                  | j                  }}||k(  r||fS t        | j                  dz  | j
                  dz  z
        }|| j
                  k(  r|t        d|       z   |t        d|      z   fS || j                  k(  r|t        | d      z   |t        |d      z   fS y)ah  The foci of the ellipse.

        Notes
        -----
        The foci can only be calculated if the major/minor axes are known.

        Raises
        ======

        ValueError
            When the major and minor axis cannot be determined.

        See Also
        ========

        sympy.geometry.point.Point
        focus_distance : Returns the distance between focus and center

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.foci
        (Point2D(-2*sqrt(2), 0), Point2D(2*sqrt(2), 0))

        r1   r   N)rE   rF   rG   r   rm   r   r"   )r>   rd   hrvrfds        rA   r   zEllipse.foci  s    < KKt||B8q6M $**a-$**a-/0a"%q5B<'7884::rc1%q5Q<'788 rC   c                 \    t        j                  | j                  | j                  d         S )a  The focal distance of the ellipse.

        The distance between the center and one focus.

        Returns
        =======

        focus_distance : number

        See Also
        ========

        foci

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.focus_distance
        2*sqrt(2)

        r   )r"   r   rE   r   ri   s    rA   r   zEllipse.focus_distance0  s!    4 ~~dkk499Q<88rC   c                      | j                   d   S )a^  The horizontal radius of the ellipse.

        Returns
        =======

        hradius : number

        See Also
        ========

        vradius, major, minor

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.hradius
        3

        r   r   ri   s    rA   rF   zEllipse.hradiusL  r   rC   c                    t        |t              r	|| v r|gS g S t        |t        t        f      r| j	                  t
        t              }t        |t        |j                  d   |j                  d         j	                  t
        t              gt
        t        gd      d   }t        t        |D cg c]  }||v st        |       c}            S t        |t              r|j                  |       S t        |t        t        f      r|| k(  r| S | j	                  t
        t              }t        t        t        ||j	                  t
        t              gt
        t        gd      d   D cg c]  }t        |       c}            S t        |t               rt#        d      t#        dt%        |      z        c c}w c c}w )aC  The intersection of this ellipse and another geometrical entity
        `o`.

        Parameters
        ==========

        o : GeometryEntity

        Returns
        =======

        intersection : list of GeometryEntity objects

        Notes
        -----
        Currently supports intersections with Point, Line, Segment, Ray,
        Circle and Ellipse types.

        See Also
        ========

        sympy.geometry.entity.GeometryEntity

        Examples
        ========

        >>> from sympy import Ellipse, Point, Line
        >>> e = Ellipse(Point(0, 0), 5, 7)
        >>> e.intersection(Point(0, 0))
        []
        >>> e.intersection(Point(5, 0))
        [Point2D(5, 0)]
        >>> e.intersection(Line(Point(0,0), Point(0, 1)))
        [Point2D(0, -7), Point2D(0, 7)]
        >>> e.intersection(Line(Point(5,0), Point(5, 1)))
        [Point2D(5, 0)]
        >>> e.intersection(Line(Point(6,0), Point(6, 1)))
        []
        >>> e = Ellipse(Point(-1, 0), 4, 3)
        >>> e.intersection(Ellipse(Point(1, 0), 4, 3))
        [Point2D(0, -3*sqrt(15)/4), Point2D(0, 3*sqrt(15)/4)]
        >>> e.intersection(Ellipse(Point(5, 0), 4, 3))
        [Point2D(2, -3*sqrt(7)/4), Point2D(2, 3*sqrt(7)/4)]
        >>> e.intersection(Ellipse(Point(100500, 0), 4, 3))
        []
        >>> e.intersection(Ellipse(Point(0, 0), 3, 4))
        [Point2D(3, 0), Point2D(-363/175, -48*sqrt(111)/175), Point2D(-363/175, 48*sqrt(111)/175)]
        >>> e.intersection(Ellipse(Point(-1, 0), 3, 4))
        [Point2D(-17/5, -12/5), Point2D(-17/5, 12/5), Point2D(7/5, -12/5), Point2D(7/5, 12/5)]
        r   r   T)set5Entity must be two dimensional, not three dimensionalzIntersection not handled for %s)r8   r"   r   r   r9   r:   r;   r,   r   pointsrX   r   Polygonintersectionr6   r    r!   	TypeErrorr/   )r>   r?   ellipse_equationresultis        rA   r   zEllipse.intersectionf  s   j aDys
	Iu-.#}}Q2,dQXXa[/**2(1a.:<=q6F 6 DaQ!Vq DEFF7#>>$''GV,-Dy#'==A#6 Gu%qzz!Q'781a&88! %"!U1X %" # $ $ >*STT=	!LMM! !E%"s   1	F;;F;,G c                     t        t              ryt        t              r: j                        }t        |t              ry|rt	         fd|D              S yt        t
              r: j                        }|syt        |      dk(  ry|d   j                  |d         S t        t        t        f      r9 j                        }t        |      dk(  r j                  |d         d   v S yt        t              rt	         fdj                  D              S t        t        t        f      rt        d      t        dt!              z        )	a  Is `o` tangent to the ellipse?

        Parameters
        ==========

        o : GeometryEntity
            An Ellipse, LinearEntity or Polygon

        Raises
        ======

        NotImplementedError
            When the wrong type of argument is supplied.

        Returns
        =======

        is_tangent: boolean
            True if o is tangent to the ellipse, False otherwise.

        See Also
        ========

        tangent_lines

        Examples
        ========

        >>> from sympy import Point, Ellipse, Line
        >>> p0, p1, p2 = Point(0, 0), Point(3, 0), Point(3, 3)
        >>> e1 = Ellipse(p0, 3, 2)
        >>> l1 = Line(p1, p2)
        >>> e1.is_tangent(l1)
        True

        FTc              3      K   | ]9  }j                  |      d    j                  j                  |      d           ; ywr   N)tangent_linesequals)rs   r   r?   r>   s     rA   ru   z%Ellipse.is_tangent.<locals>.<genexpr>  s<     gXYD..q1!4<<Q__Q=OPQ=RSgs   ?Ar   r   c              3   @   K   | ]  }j                  |        y wrK   )
is_tangent)rs   sr>   s     rA   ru   z%Ellipse.is_tangent.<locals>.<genexpr>  s     ;atq);s   r   zIs_tangent not handled for %s)r8   r#   r6   r   allr    rU   r   r   r   r   r   sidesr!   r$   r   r/   )r>   r?   	intersecthits   ``  rA   r   zEllipse.is_tangent  s3   J a!7#))!,I)W-g]fggg6"##A&C3x1}q6==Q((Iu-.))!,I9~"D..y|<Q???7#;177;;;NG45STT;ilJKKrC   c                     | j                   dd }t        |      dk(  r|d   S |\  }}||z
  dk  }|dk(  r|S |dk(  r|S | j                  S )a  Longer axis of the ellipse (if it can be determined) else hradius.

        Returns
        =======

        major : number or expression

        See Also
        ========

        hradius, vradius, minor

        Examples
        ========

        >>> from sympy import Point, Ellipse, Symbol
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.major
        3

        >>> a = Symbol('a')
        >>> b = Symbol('b')
        >>> Ellipse(p1, a, b).major
        a
        >>> Ellipse(p1, b, a).major
        b

        >>> m = Symbol('m')
        >>> M = m + 1
        >>> Ellipse(p1, m, M).major
        m + 1

        r   r   r   TF)r   rU   rF   r>   abr   r   r?   s        rA   rm   zEllipse.major  `    H YYq^r7a<a5L1EAI9H%ZH||rC   c                     | j                   dd }t        |      dk(  r|d   S |\  }}||z
  dk  }|dk(  r|S |dk(  r|S | j                  S )a  Shorter axis of the ellipse (if it can be determined) else vradius.

        Returns
        =======

        minor : number or expression

        See Also
        ========

        hradius, vradius, major

        Examples
        ========

        >>> from sympy import Point, Ellipse, Symbol
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.minor
        1

        >>> a = Symbol('a')
        >>> b = Symbol('b')
        >>> Ellipse(p1, a, b).minor
        b
        >>> Ellipse(p1, b, a).minor
        a

        >>> m = Symbol('m')
        >>> M = m + 1
        >>> Ellipse(p1, m, M).minor
        m

        r   r   r   TF)r   rU   rG   r   s        rA   r   zEllipse.minor+  r   rC   c                    t        |d      }	 g }|j                  | j                  j                  k(  r*|j                  t	        | j                  t
                     |j                  | j                  j                  k(  r&|j                  t	        | j                  d             |r|S | j                  t        t              }t        |t        t              }d|z  }t	        |t        t        f      j                  }||z
  }t        |t              d   }	|j                  t        |	      j                         d   j                         }
t        |
j                        dk(  r^	 t!        |
t              j#                         }|D cg c]3  }t        |t        |j                  t        |      t              d         5 }}nt)        d	      |D cg c]1  }|j                  t-        t        t        f|j.                              3 }}|I|D cg c]  }|j1                  |       }}|D cg c]   }t3        |      r|n|j1                  |      " }}t-        ||      D cg c]  \  }}t	        ||       c}}S # t$        t&        t(        f$ r" t+        t        |
t              d      d   }Y 0w xY wc c}w c c}w c c}w c c}w c c}}w )
aA  Normal lines between `p` and the ellipse.

        Parameters
        ==========

        p : Point

        Returns
        =======

        normal_lines : list with 1, 2 or 4 Lines

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> e = Ellipse((0, 0), 2, 3)
        >>> c = e.center
        >>> e.normal_lines(c + Point(1, 0))
        [Line2D(Point2D(0, 0), Point2D(1, 0))]
        >>> e.normal_lines(c)
        [Line2D(Point2D(0, 0), Point2D(0, 1)), Line2D(Point2D(0, 0), Point2D(1, 0))]

        Off-axis points require the solution of a quartic equation. This
        often leads to very large expressions that may be of little practical
        use. An approximate solution of `prec` digits can be obtained by
        passing in the desired value:

        >>> e.normal_lines((3, 3), prec=2)
        [Line2D(Point2D(-0.81, -2.7), Point2D(0.19, -1.2)),
        Line2D(Point2D(1.5, -2.0), Point2D(2.5, -2.7))]

        Whereas the above solution has an operation count of 12, the exact
        solution has an operation count of 2020.
        r1   rP   T)sloper   r   )	separatedz7intersections for the general ellipse are not supported)r"   r:   rE   appendr   r   r;   r9   r%   r   r,   r<   as_numer_denomexpandrU   rv   r(   
real_rootsr'   r)   r   r+   zipr   nr*   )r>   r   precrveqdydxnormr   seqyisxeqxsolr   r   ptslopesr   s                    rA   normal_lineszEllipse.normal_linesZ  sF   H !O
 Bssdkkmm#		$t{{"56ssdkkmm#		$t{{!45 	 ]]1a RA$wQA%%dl CmAggao,,.q188:s A%@C|..0 EIIqeAuRWWQ]A6q9:IFI%IK K<BCb$))CA01CC+12Rbdd4j2F2CIJa<?aD	9JFJ/266/BCeb!Rq!CC  2EF @eCmt<Q?@ J D2JCs0   %I> 8J76J<K-%K#K>2J43J4c                 :    | j                   d| j                  z
  z  S )a  The periapsis of the ellipse.

        The shortest distance between the focus and the contour.

        Returns
        =======

        periapsis : number

        See Also
        ========

        apoapsis : Returns greatest distance between focus and contour

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.periapsis
        3 - 2*sqrt(2)

        r   rl   ri   s    rA   	periapsiszEllipse.periapsis  ro   rC   c                 @    | j                   d| j                  dz  z
  z  S )a@  
        Calculates the semi-latus rectum of the Ellipse.

        Semi-latus rectum is defined as one half of the chord through a
        focus parallel to the conic section directrix of a conic section.

        Returns
        =======

        semilatus_rectum : number

        See Also
        ========

        apoapsis : Returns greatest distance between focus and contour

        periapsis : The shortest distance between the focus and the contour

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.semilatus_rectum
        1/3

        References
        ==========

        .. [1] https://mathworld.wolfram.com/SemilatusRectum.html
        .. [2] https://en.wikipedia.org/wiki/Ellipse#Semi-latus_rectum

        r   r1   rl   ri   s    rA   semilatus_rectumzEllipse.semilatus_rectum  s$    H zzQ!2!2a!7788rC   c                 j    t        | j                  t        | j                  | j                              S )a  Returns a Circle whose diameter is the major axis of the ellipse.

        Examples
        ========

        >>> from sympy import Ellipse, Point, symbols
        >>> c = Point(1, 2)
        >>> Ellipse(c, 8, 7).auxiliary_circle()
        Circle(Point2D(1, 2), 8)
        >>> a, b = symbols('a b')
        >>> Ellipse(c, a, b).auxiliary_circle()
        Circle(Point2D(1, 2), Max(a, b))
        )r[   rE   r   rF   rG   ri   s    rA   auxiliary_circlezEllipse.auxiliary_circle  s$     dkk3t||T\\#BCCrC   c                 z    t        | j                  t        | j                  dz  | j                  dz  z               S )a  
        Returns a Circle consisting of all points where two perpendicular
        tangent lines to the ellipse cross each other.

        Returns
        =======

        Circle
            A director circle returned as a geometric object.

        Examples
        ========

        >>> from sympy import Ellipse, Point, symbols
        >>> c = Point(3,8)
        >>> Ellipse(c, 7, 9).director_circle()
        Circle(Point2D(3, 8), sqrt(130))
        >>> a, b = symbols('a b')
        >>> Ellipse(c, a, b).director_circle()
        Circle(Point2D(3, 8), sqrt(a**2 + b**2))

        References
        ==========

        .. [1] https://en.wikipedia.org/wiki/Director_circle

        r1   )r[   rE   r   rF   rG   ri   s    rA   director_circlezEllipse.director_circle  s/    8 dkk4a$,,/(I#JKKrC   c                 `    t        |d      }|t        j                   t        j                  gS )a  The plot interval for the default geometric plot of the Ellipse.

        Parameters
        ==========

        parameter : str, optional
            Default value is 't'.

        Returns
        =======

        plot_interval : list
            [parameter, lower_bound, upper_bound]

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> e1 = Ellipse(Point(0, 0), 3, 2)
        >>> e1.plot_interval()
        [t, -pi, pi]

        Tr3   )r   r   r|   rw   s      rA   plot_intervalzEllipse.plot_interval  s'    0 ID)ADD5!$$rC   c                 t   t        dd      }| j                  |      j                  \  }}|t        j                  |      }nt        }t        |j                               }d|z  dz
  }t        d|dz  z
        }t        |j                  t        |      |      |j                  t        |      |            S )aP  A random point on the ellipse.

        Returns
        =======

        point : Point

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> e1 = Ellipse(Point(0, 0), 3, 2)
        >>> e1.random_point() # gives some random point
        Point2D(...)
        >>> p1 = e1.random_point(seed=0); p1.n(2)
        Point2D(2.1, 1.4)

        Notes
        =====

        When creating a random point, one may simply replace the
        parameter with a random number. When doing so, however, the
        random number should be made a Rational or else the point
        may not test as being in the ellipse:

        >>> from sympy.abc import t
        >>> from sympy import Rational
        >>> arb = e1.arbitrary_point(t); arb
        Point2D(3*cos(t), 2*sin(t))
        >>> arb.subs(t, .1) in e1
        False
        >>> arb.subs(t, Rational(.1)) in e1
        True
        >>> arb.subs(t, Rational('.1')) in e1
        True

        See Also
        ========
        sympy.geometry.point.Point
        arbitrary_point : Returns parameterized point on ellipse
        ry   Tr3   r1   r   )r   rz   r   randomRandomr   r   r"   r<   r   r   )	r>   seedry   r:   r;   rngrrd   r   s	            rA   random_pointzEllipse.random_point5  s    T Cd###A&++1 --%CCSZZ\"aC!GQTNQVVCFA&s1vq(9::rC   c                 &   |j                   dt        fv rE| j                  }|j                  |      }| j	                  || j
                   | j                        S dD cg c]  }t        || |fd d       c}\  }}| j                  ||      }t        ||      j                  |      }|j                  t        ||f|j                        d      }t        t        ddt        |      d	t        |      d
t        |      z               c c}w )a  Override GeometryEntity.reflect since the radius
        is not a GeometryEntity.

        Examples
        ========

        >>> from sympy import Circle, Line
        >>> Circle((0, 1), 1).reflect(Line((0, 0), (1, 1)))
        Circle(Point2D(1, 0), -1)
        >>> from sympy import Ellipse, Line, Point
        >>> Ellipse(Point(3, 4), 1, 3).reflect(Line(Point(0, -4), Point(5, 0)))
        Traceback (most recent call last):
        ...
        NotImplementedError:
        General Ellipse is not supported but the equation of the reflected
        Ellipse is given by the zeros of: f(x, y) = (9*x/41 + 40*y/41 +
        37/41)**2 + (40*x/123 - 3*y/41 - 364/123)**2 - 1

        Notes
        =====

        Until the general ellipse (with no axis parallel to the x-axis) is
        supported a NotImplemented error is raised and the equation whose
        zeros define the rotated ellipse is given.

        r   xyc                     d| z   S )N_rS   )r   s    rA   rT   z!Ellipse.reflect.<locals>.<lambda>  s
    S1W rC   T)modifyr4   )simultaneouszeGeneral Ellipse is not supported but the equation of the reflected Ellipse is given by the zeros of: zf(z, z) = )r   r   rE   reflectfuncrF   rG   r   r9   r"   r<   r   r   r   r.   str)	r>   linerd   rr   r:   r;   exprr   r   s	            rA   r   zEllipse.reflectm  s   8 ::!R A		$A99Qt||<< !" *tTl+<4I "DAq ==A&Da##D)AYYsAq6166  %37  9F%jF$'FCFCK@A'B C C"s   Dc                    | j                   | j                  k(  r6| j                  | j                  j	                  ||      | j                         S |t
        j                  z  j                  rt        |   ||      S d|z  t
        j                  z  j                  rA| j                  | j                  j	                  ||      | j                  | j                         S t        d      )a  Rotate ``angle`` radians counterclockwise about Point ``pt``.

        Note: since the general ellipse is not supported, only rotations that
        are integer multiples of pi/2 are allowed.

        Examples
        ========

        >>> from sympy import Ellipse, pi
        >>> Ellipse((1, 0), 2, 1).rotate(pi/2)
        Ellipse(Point2D(0, 1), 1, 2)
        >>> Ellipse((1, 0), 2, 1).rotate(pi)
        Ellipse(Point2D(-1, 0), 2, 1)
        r1   z;Only rotations of pi/2 are currently supported for Ellipse.)
rF   rG   r   rE   rotater   r|   
is_integerrL   r   )r>   angler   rN   s      rA   r   zEllipse.rotate  s     <<4<<'99T[[//r:DLLII!$$J""7>%,,eGADDL$$99T[[//r:DLL$,,WW!"_``rC   c                 >   | j                   }|rNt        |d      }  | j                  | j                   j	                  ||      j                  |j                   S | j
                  }| j                  }| j                  |j	                  ||      ||z  ||z        S )at  Override GeometryEntity.scale since it is the major and minor
        axes which must be scaled and they are not GeometryEntities.

        Examples
        ========

        >>> from sympy import Ellipse
        >>> Ellipse((0, 0), 2, 1).scale(2, 4)
        Circle(Point2D(0, 0), 4)
        >>> Ellipse((0, 0), 2, 1).scale(2)
        Ellipse(Point2D(0, 0), 4, 1)
        r1   rP   rF   rG   )rE   r"   	translater   scalerF   rG   r   )r>   r:   r;   r   rd   re   rf   s          rA   r   zEllipse.scale  s     KKrq!BD>4>>RC::.44Q:DDbggNNLLLLyyA!QqSyAArC   c           	         t        |d      }| j                  |      rg S || v r| j                  |z
  }| j                  dz  |j                  z  }| j
                  dz   |j                  z  }t        t        |j                  |z         t        |j                  |z               }t        ||      gS t        | j                        dk(  rO| j                  \  }}| j
                  }d|z  t        j                  ||      z
  t        j                  ||      z
  }	n-| j                  t        j                  | j                  |      z
  }	|	j                  r|	j                  rg S | j                  t        t              }
t!        |
t        t              }t        |t        t        t                    j"                  }t%        ||z
  |
gt        t        g      }t        |      dk(  r|d   d   |j                  k(  s|d   d   |j                  k(  r2t        ||t        dd      z         t        ||t        dd      z         gS t        ||t        dd      z         t        ||d         gS t        ||d         t        ||d         gS )a`  Tangent lines between `p` and the ellipse.

        If `p` is on the ellipse, returns the tangent line through point `p`.
        Otherwise, returns the tangent line(s) from `p` to the ellipse, or
        None if no tangent line is possible (e.g., `p` inside ellipse).

        Parameters
        ==========

        p : Point

        Returns
        =======

        tangent_lines : list with 1 or 2 Lines

        Raises
        ======

        NotImplementedError
            Can only find tangent lines for a point, `p`, on the ellipse.

        See Also
        ========

        sympy.geometry.point.Point, sympy.geometry.line.Line

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> e1 = Ellipse(Point(0, 0), 3, 2)
        >>> e1.tangent_lines(Point(3, 0))
        [Line2D(Point2D(3, 0), Point2D(3, -12))]

        r1   rP   r   r   )r"   r   rE   rG   r:   rF   r;   r   r   rU   r   r   r   	is_numberr   r9   r%   r   r,   )r>   r   deltariserunp2f1f2majr   r   r   r   tangent_pointss                 rA   r   zEllipse.tangent_lines  s2   J !Oq!I9KK!OELL!OUWW,DLL!O$UWW,Cxc	*d
+-BBK= 499~"Bll#r1-.r1-. {{U^^DKK%CC~~$"2"2	 q!$BQ?DE!QK(..E #EDL"#51v>N >"a'!!$!"%(6q(9!(<(C AaO4d1a%1+o6NOO AaO4d1nQ>O6PQQ N1-.Qq8I0JKKrC   c                      | j                   d   S )a\  The vertical radius of the ellipse.

        Returns
        =======

        vradius : number

        See Also
        ========

        hradius, major, minor

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.vradius
        1

        r1   r   ri   s    rA   rG   zEllipse.vradius  r   rC   c                 ,   t         j                  | j                  z  | j                  dz  z  dz  }t         j                  | j                  dz  z  | j                  z  dz  }d}||||fS || j                  |d   | j
                  j                  z
  dz  z  z   }|| j                  |d   | j
                  j                  z
  dz  z  z   }|| j                  |d   | j
                  j                  z
  z  |d   | j
                  j                  z
  z  z   }|||fS )a  Returns the second moment and product moment area of an ellipse.

        Parameters
        ==========

        point : Point, two-tuple of sympifiable objects, or None(default=None)
            point is the point about which second moment of area is to be found.
            If "point=None" it will be calculated about the axis passing through the
            centroid of the ellipse.

        Returns
        =======

        I_xx, I_yy, I_xy : number or SymPy expression
            I_xx, I_yy are second moment of area of an ellise.
            I_xy is product moment of area of an ellipse.

        Examples
        ========

        >>> from sympy import Point, Ellipse
        >>> p1 = Point(0, 0)
        >>> e1 = Ellipse(p1, 3, 1)
        >>> e1.second_moment_of_area()
        (3*pi/4, 27*pi/4, 0)

        References
        ==========

        .. [1] https://en.wikipedia.org/wiki/List_of_second_moments_of_area

        r   r   r   r   r1   )r   r|   rF   rG   r}   rE   r;   r:   )r>   pointI_xxI_yyI_xys        rA   second_moment_of_areazEllipse.second_moment_of_area2  s    D dll#T\\1_5q8dllAo&5q8=t## dii%(T[[]]":Q!>??dii%(T[[]]":Q!>??diiqDKKMM!9:E!Ht{{}}<TUUT4rC   c                 8    | j                         }|d   |d   z   S )a  Returns the polar second moment of area of an Ellipse

        It is a constituent of the second moment of area, linked through
        the perpendicular axis theorem. While the planar second moment of
        area describes an object's resistance to deflection (bending) when
        subjected to a force applied to a plane parallel to the central
        axis, the polar second moment of area describes an object's
        resistance to deflection when subjected to a moment applied in a
        plane perpendicular to the object's central axis (i.e. parallel to
        the cross-section)

        Examples
        ========

        >>> from sympy import symbols, Circle, Ellipse
        >>> c = Circle((5, 5), 4)
        >>> c.polar_second_moment_of_area()
        128*pi
        >>> a, b = symbols('a, b')
        >>> e = Ellipse((0, 0), a, b)
        >>> e.polar_second_moment_of_area()
        pi*a**3*b/4 + pi*a*b**3/4

        References
        ==========

        .. [1] https://en.wikipedia.org/wiki/Polar_moment_of_inertia

        r   r   )r  )r>   second_moments     rA   polar_second_moment_of_areaz#Ellipse.polar_second_moment_of_areac  s'    < 224Q-"222rC   c                 *   | j                   \  }}|6| j                  \  }}}}t        ||z
  ||z
        }t        ||z
  ||z
        }	n)t        |      }|j                  |z
  }|j
                  |z
  }	| j                         }
|
d   |z  }|
d   |	z  }||fS )a  Returns a tuple with the section modulus of an ellipse

        Section modulus is a geometric property of an ellipse defined as the
        ratio of second moment of area to the distance of the extreme end of
        the ellipse from the centroidal axis.

        Parameters
        ==========

        point : Point, two-tuple of sympifyable objects, or None(default=None)
            point is the point at which section modulus is to be found.
            If "point=None" section modulus will be calculated for the
            point farthest from the centroidal axis of the ellipse.

        Returns
        =======

        S_x, S_y: numbers or SymPy expressions
                  S_x is the section modulus with respect to the x-axis
                  S_y is the section modulus with respect to the y-axis
                  A negative sign indicates that the section modulus is
                  determined for a point below the centroidal axis.

        Examples
        ========

        >>> from sympy import Symbol, Ellipse, Circle, Point2D
        >>> d = Symbol('d', positive=True)
        >>> c = Circle((0, 0), d/2)
        >>> c.section_modulus()
        (pi*d**3/32, pi*d**3/32)
        >>> e = Ellipse(Point2D(0, 0), 2, 4)
        >>> e.section_modulus()
        (8*pi, 4*pi)
        >>> e.section_modulus((2, 2))
        (16*pi, 4*pi)

        References
        ==========

        .. [1] https://en.wikipedia.org/wiki/Section_modulus

        r   r   )rE   r   maxr#   r;   r:   r  )r>   r
  x_cy_cx_miny_minx_maxy_maxr;   r:   r  S_xS_ys                rA   section_moduluszEllipse.section_modulus  s    X ;;S=)-&E5%C%K-AC%K-A ENE#A#A224Aq Aq CxrC   )NNNN)g      ?z#66cc99)ry   )r:   r;   Nr:   r;   rK   r   r   r   N),__name__
__module____qualname____doc__rB   rI   rM   r]   rg   propertyrj   rn   rz   r}   r   rE   r   r_   r   r9   r   r   r   rF   r   r   rm   r   r   r   r   r   r   r   r   r   r   r   r   rG   r  r  r  __classcell__)rN   s   @rA   r6   r6   (   s   ?BF" DH$OL@&   4 46':R < <( \ \  2 A A, 0 0(3,jJXM@ *9 *9X 9 96  2PNdBLH , ,\ , ,\ND` 4 46 #9 #9JD L< 66;p+CZa0B*NL`  4. b3D<rC   r6   c                   j    e Zd ZdZd ZddZed        ZddZd Z	ed        Z
d Zdd
Zed        Zy	)r[   a  A circle in space.

    Constructed simply from a center and a radius, from three
    non-collinear points, or the equation of a circle.

    Parameters
    ==========

    center : Point
    radius : number or SymPy expression
    points : sequence of three Points
    equation : equation of a circle

    Attributes
    ==========

    radius (synonymous with hradius, vradius, major and minor)
    circumference
    equation

    Raises
    ======

    GeometryError
        When the given equation is not that of a circle.
        When trying to construct circle from incorrect parameters.

    See Also
    ========

    Ellipse, sympy.geometry.point.Point

    Examples
    ========

    >>> from sympy import Point, Circle, Eq
    >>> from sympy.abc import x, y, a, b

    A circle constructed from a center and radius:

    >>> c1 = Circle(Point(0, 0), 5)
    >>> c1.hradius, c1.vradius, c1.radius
    (5, 5, 5)

    A circle constructed from three points:

    >>> c2 = Circle(Point(0, 0), Point(1, 1), Point(1, 0))
    >>> c2.hradius, c2.vradius, c2.radius, c2.center
    (sqrt(2)/2, sqrt(2)/2, sqrt(2)/2, Point2D(1/2, 1/2))

    A circle can be constructed from an equation in the form
    `a*x**2 + by**2 + gx + hy + c = 0`, too:

    >>> Circle(x**2 + y**2 - 25)
    Circle(Point2D(0, 0), 5)

    If the variables corresponding to x and y are named something
    else, their name or symbol can be supplied:

    >>> Circle(Eq(a**2 + b**2, 25), x='a', y=b)
    Circle(Point2D(0, 0), 5)
    c                 |   |j                  dt        j                        }t        |      dk(  rt	        |d   t
        t        f      r|j                  dd      }|j                  dd      }|d   j                         }t	        |t              r|j                  |j                  z
  }t        ||      }t        ||      }	 t        ||dz  |dz  ||      \  }}}	}
}t        j                  ||fv s||k7  rt        d      |	 |z  dz  }|
 |z  dz  }|dz  |dz  z   ||z  z
  }t!        ||ft#        |      |      S d	\  }	}t        |      d
k(  rN|D cg c]  }t%        |d|       }}t'        | }t	        |t&              s|S |j(                  }	|j*                  }n=t        |      dk(  r/t%        |d   d|      }	|d   }	 t%        |d|      j,                  }|	!||dk(  r|	S t/        j0                  | |	|fi |S t        d      # t        $ r t        d      w xY wc c}w # t        $ r t        d      w xY w)Nevaluater   r   r:   r;   r1   z+The given equation is not that of a circle.r'  )NNr   )rQ   r'  z-Circle with imaginary radius is not permittedz)Circle.__new__ received unknown arguments)getr	   r'  rU   r8   r   r   r   lhsrhsr&   r-   rV   r   r   r=   r[   r   r"   Trianglecircumcentercircumradiusr:   r   r]   )r^   r   r`   r'  r:   r;   r9   r   r   rd   decenter_xcenter_yr2r   ry   s                    rA   r]   zCircle.__new__  sU   ::j*;*D*DEt9>ja4*=

3$A

3$AAw~~'H(B'#<<(,,6Q!AQ!AS -h1adAq I1aA vv!Q16#$QRRr!tAvHr!tAvHA+(A+.14B8X.R8LL DAq4yA~DHIqaQ:IIdO!!X.HNNNNTa$q'q8<GYaX688A I6H%--c1aB6BB KLLI  S#$QRRS J " Y'(WXXYs   H	 H!H& 	H&H;c                     | j                   \  }}t        |      } |j                  dd|i|} |j                  dd|i|}| j                  ||d      S )Nr   Fr(  rS   )r   r0   evalfr   )r>   r   optionsr   r   dpss         rA   _eval_evalfzCircle._eval_evalf7  s^    		A$RXX''w'AGG%c%W%yyQy//rC   c                 B    dt         j                  z  | j                  z  S )a"  The circumference of the circle.

        Returns
        =======

        circumference : number or SymPy expression

        Examples
        ========

        >>> from sympy import Point, Circle
        >>> c1 = Circle(Point(3, 4), 6)
        >>> c1.circumference
        12*pi

        r1   )r   r|   r   ri   s    rA   r   zCircle.circumference>  s    $ 144x$++%%rC   c                     t        |d      }t        |d      }|| j                  j                  z
  dz  }|| j                  j                  z
  dz  }||z   | j                  dz  z
  S )a  The equation of the circle.

        Parameters
        ==========

        x : str or Symbol, optional
            Default value is 'x'.
        y : str or Symbol, optional
            Default value is 'y'.

        Returns
        =======

        equation : SymPy expression

        Examples
        ========

        >>> from sympy import Point, Circle
        >>> c1 = Circle(Point(0, 0), 5)
        >>> c1.equation()
        x**2 + y**2 - 25

        Tr3   r1   )r   rE   r:   r;   rm   r   s        rA   r9   zCircle.equationR  sa    2 AD!AD!$++--!#$++--!#BwQ&&rC   c                 .    t         j                  | |      S )a  The intersection of this circle with another geometrical entity.

        Parameters
        ==========

        o : GeometryEntity

        Returns
        =======

        intersection : list of GeometryEntities

        Examples
        ========

        >>> from sympy import Point, Circle, Line, Ray
        >>> p1, p2, p3 = Point(0, 0), Point(5, 5), Point(6, 0)
        >>> p4 = Point(5, 0)
        >>> c1 = Circle(p1, 5)
        >>> c1.intersection(p2)
        []
        >>> c1.intersection(p4)
        [Point2D(5, 0)]
        >>> c1.intersection(Ray(p1, p2))
        [Point2D(5*sqrt(2)/2, 5*sqrt(2)/2)]
        >>> c1.intersection(Line(p2, p3))
        []

        )r6   r   rH   s     rA   r   zCircle.intersectionq  s    < ##D!,,rC   c                      | j                   d   S )at  The radius of the circle.

        Returns
        =======

        radius : number or SymPy expression

        See Also
        ========

        Ellipse.major, Ellipse.minor, Ellipse.hradius, Ellipse.vradius

        Examples
        ========

        >>> from sympy import Point, Circle
        >>> c1 = Circle(Point(3, 4), 6)
        >>> c1.radius
        6

        r   r   ri   s    rA   r   zCircle.radius  s    . yy|rC   c                 v    | j                   }|j                  |      }| j                  || j                         S )a  Override GeometryEntity.reflect since the radius
        is not a GeometryEntity.

        Examples
        ========

        >>> from sympy import Circle, Line
        >>> Circle((0, 1), 1).reflect(Line((0, 0), (1, 1)))
        Circle(Point2D(1, 0), -1)
        )rE   r   r   r   )r>   r   rd   s      rA   r   zCircle.reflect  s1     KKIIdOyyT[[L))rC   Nc                    | j                   }|rNt        |d      }  | j                  | j                   j	                  ||      j                  |j                   S |j	                  ||      }||fD cg c]  }t        |       c}\  }}||k(  r| j                  ||| j                  z        S | j                  x}}t        |||z  ||z        S c c}w )a;  Override GeometryEntity.scale since the radius
        is not a GeometryEntity.

        Examples
        ========

        >>> from sympy import Circle
        >>> Circle((0, 0), 1).scale(2, 2)
        Circle(Point2D(0, 0), 2)
        >>> Circle((0, 0), 1).scale(2, 4)
        Ellipse(Point2D(0, 0), 2, 4)
        r1   rP   r   )	rE   r"   r   r   r   absr   r   r6   )r>   r:   r;   r   rd   r   re   rf   s           rA   r   zCircle.scale  s     KKrq!BD>4>>RC::.44Q:DDbggNNGGAqM!"A'1A'1699Q$++..Aq!A#qs33	 (s   5Cc                 ,    t        | j                        S )a  
        This Ellipse property is an alias for the Circle's radius.

        Whereas hradius, major and minor can use Ellipse's conventions,
        the vradius does not exist for a circle. It is always a positive
        value in order that the Circle, like Polygons, will have an
        area that can be positive or negative as determined by the sign
        of the hradius.

        Examples
        ========

        >>> from sympy import Point, Circle
        >>> c1 = Circle(Point(3, 4), 6)
        >>> c1.vradius
        6
        )r?  r   ri   s    rA   rG   zCircle.vradius  s    & 4;;rC   )   r  r  )r  r   r!  r"  r]   r8  r#  r   r9   r   r   r   r   rG   rS   rC   rA   r[   r[     se    =~1Mf0 & &&'>-@  0*40    rC   r[   )r   r,  )Or"  sympy.core.exprr   sympy.core.relationalr   
sympy.corer   r   r   sympy.core.evalfr   sympy.core.parametersr	   sympy.core.logicr
   sympy.core.numbersr   r   sympy.core.sortingr   sympy.core.symbolr   r   r   sympy.simplifyr   r   (sympy.functions.elementary.miscellaneousr   r   (sympy.functions.elementary.trigonometricr   r   *sympy.functions.special.elliptic_integralsr   entityr   r   
exceptionsr   r   r   r   r   r   r    r!   r
  r"   r#   r$   utilr%   r&   sympy.polysr'   r(   r)   sympy.polys.polyutilsr*   r+   sympy.solversr,   sympy.solvers.solvesetr-   sympy.utilities.miscr.   r/   mpmath.libmp.libmpfr0   r   ranger:   r;   r6   r[   polygonr   r,  )r   s   0rA   <module>rZ     s    ! $ % %  3 ' + & C C - > = A / % I I * *  : : 6  0 6 + 388<aoD)<1Yk Yx,` W ` F	 ' &E6 =s   D