ó
~9­\c           @  sæ   d  Z  d d l 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 m Z d d l m Z m Z d d l m Z m Z d d	 l m Z m Z m Z m Z m Z d d
 l m Z d e f d „  ƒ  YZ d S(   s4   Parabolic geometrical entity.

Contains
* Parabola

iÿÿÿÿ(   t   divisiont   print_function(   t   S(   t   ordered(   t   _symbol(   t   symbolst   simplifyt   solve(   t   GeometryEntityt   GeometrySet(   t   Pointt   Point2D(   t   Linet   Line2Dt   Ray2Dt	   Segment2Dt   LinearEntity3D(   t   Ellipset   Parabolac           B  s­   e  Z d  Z d d d „ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 d d d „ Z
 e d	 „  ƒ Z e d
 „  ƒ Z d „  Z e d „  ƒ Z e d „  ƒ Z RS(   s•  A parabolic GeometryEntity.

    A parabola is declared with a point, that is called 'focus', and
    a line, that is called 'directrix'.
    Only vertical or horizontal parabolas are currently supported.

    Parameters
    ==========

    focus : Point
        Default value is Point(0, 0)
    directrix : Line

    Attributes
    ==========

    focus
    directrix
    axis of symmetry
    focal length
    p parameter
    vertex
    eccentricity

    Raises
    ======
    ValueError
        When `focus` is not a two dimensional point.
        When `focus` is a point of directrix.
    NotImplementedError
        When `directrix` is neither horizontal nor vertical.

    Examples
    ========

    >>> from sympy import Parabola, Point, Line
    >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7,8)))
    >>> p1.focus
    Point2D(0, 0)
    >>> p1.directrix
    Line2D(Point2D(5, 8), Point2D(7, 8))

    c         K  sš   | r t  | d d ƒ} n t  d d ƒ } t | ƒ } | j d k rf | j t j k rf t d ƒ ‚ n  | j | ƒ r„ t d ƒ ‚ n  t j	 |  | | |  S(   Nt   dimi   i    s3   The directrix must be a horizontal or vertical lines*   The focus must not be a point of directrix(
   R
   R   t   slopeR   t   Infinityt   NotImplementedErrort   containst
   ValueErrorR   t   __new__(   t   clst   focust	   directrixt   kwargs(    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyR   @   s    !c         C  s
   t  d ƒ S(   sX  Returns the ambient dimension of parabola.

        Returns
        =======

        ambient_dimension : integer

        Examples
        ========

        >>> from sympy import Parabola, Point, Line
        >>> f1 = Point(0, 0)
        >>> p1 = Parabola(f1, Line(Point(5, 8), Point(7, 8)))
        >>> p1.ambient_dimension
        2

        i   (   R   (   t   self(    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyt   ambient_dimensionQ   s    c         C  s   |  j  j |  j ƒ S(   s¢  The axis of symmetry of the parabola.

        Returns
        =======

        axis_of_symmetry : Line

        See Also
        ========

        sympy.geometry.line.Line

        Examples
        ========

        >>> from sympy import Parabola, Point, Line
        >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8)))
        >>> p1.axis_of_symmetry
        Line2D(Point2D(0, 0), Point2D(0, 1))

        (   R   t   perpendicular_lineR   (   R   (    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyt   axis_of_symmetryf   s    c         C  s   |  j  d S(   s¡  The directrix of the parabola.

        Returns
        =======

        directrix : Line

        See Also
        ========

        sympy.geometry.line.Line

        Examples
        ========

        >>> from sympy import Parabola, Point, Line
        >>> l1 = Line(Point(5, 8), Point(7, 8))
        >>> p1 = Parabola(Point(0, 0), l1)
        >>> p1.directrix
        Line2D(Point2D(5, 8), Point2D(7, 8))

        i   (   t   args(   R   (    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyR      s    c         C  s
   t  d ƒ S(   s×  The eccentricity of the parabola.

        Returns
        =======

        eccentricity : number

        A parabola may also be characterized as a conic section with an
        eccentricity of 1. As a consequence of this, all parabolas are
        similar, meaning that while they can be different sizes,
        they are all the same shape.

        See Also
        ========

        https://en.wikipedia.org/wiki/Parabola


        Examples
        ========

        >>> from sympy import Parabola, Point, Line
        >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8)))
        >>> p1.eccentricity
        1

        Notes
        -----
        The eccentricity for every Parabola is 1 by definition.

        i   (   R   (   R   (    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyt   eccentricity™   s    !t   xt   yc         C  sŸ   t  | d t ƒ} t  | d t ƒ} |  j j d k rh d |  j | |  j j } | |  j j d } n/ d |  j | |  j j } | |  j j d } | | S(   sz  The equation of the parabola.

        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 Parabola, Point, Line
        >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8)))
        >>> p1.equation()
        -x**2 - 16*y + 64
        >>> p1.equation('f')
        -f**2 - 16*y + 64
        >>> p1.equation(y='z')
        -x**2 - 16*z + 64

        t   reali    i   i   (   R   t   TrueR!   R   t   p_parametert   vertexR$   R%   (   R   R$   R%   t   t1t   t2(    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyt   equation¼   s    c         C  s#   |  j  j |  j ƒ } | d } | S(   sY  The focal length of the parabola.

        Returns
        =======

        focal_lenght : number or symbolic expression

        Notes
        =====

        The distance between the vertex and the focus
        (or the vertex and directrix), measured along the axis
        of symmetry, is the "focal length".

        See Also
        ========

        https://en.wikipedia.org/wiki/Parabola

        Examples
        ========

        >>> from sympy import Parabola, Point, Line
        >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8)))
        >>> p1.focal_length
        4

        i   (   R   t   distanceR   (   R   R-   t   focal_length(    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyR.   ã   s    
c         C  s   |  j  d S(   s  The focus of the parabola.

        Returns
        =======

        focus : Point

        See Also
        ========

        sympy.geometry.point.Point

        Examples
        ========

        >>> from sympy import Parabola, Point, Line
        >>> f1 = Point(0, 0)
        >>> p1 = Parabola(f1, Line(Point(5, 8), Point(7, 8)))
        >>> p1.focus
        Point2D(0, 0)

        i    (   R"   (   R   (    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyR     s    c         C  sî  t  d d t ƒ\ } } |  j ƒ  } t | t ƒ r | |  k rF | g St t g  t | | j ƒ  g | | g ƒ D] } t | ƒ ^ qn ƒ ƒ Sn]t | t	 ƒ rå t
 | j | | j d f | | j d f g ƒ ƒ d k rÞ | g Sg  Snt | t t f ƒ rgt | t | j d | j d ƒ j ƒ  g | | g ƒ } t t g  | D] } | | k r?t	 | ƒ ^ q?ƒ ƒ St | t t f ƒ rÀt t g  t | | j ƒ  g | | g ƒ D] } t	 | ƒ ^ q¤ƒ ƒ St | t ƒ rÞt d ƒ ‚ n t d ƒ ‚ d S(   sú  The intersection of the parabola and another geometrical entity `o`.

        Parameters
        ==========

        o : GeometryEntity, LinearEntity

        Returns
        =======

        intersection : list of GeometryEntity objects

        Examples
        ========

        >>> from sympy import Parabola, Point, Ellipse, Line, Segment
        >>> p1 = Point(0,0)
        >>> l1 = Line(Point(1, -2), Point(-1,-2))
        >>> parabola1 = Parabola(p1, l1)
        >>> parabola1.intersection(Ellipse(Point(0, 0), 2, 5))
        [Point2D(-2, 0), Point2D(2, 0)]
        >>> parabola1.intersection(Line(Point(-7, 3), Point(12, 3)))
        [Point2D(-4, 3), Point2D(4, 3)]
        >>> parabola1.intersection(Segment((-12, -65), (14, -68)))
        []

        s   x yR&   i    i   s5   Entity must be two dimensional, not three dimensionals   Wrong type of argument were putN(   R   R'   R,   t
   isinstanceR   t   listR   R   R
   R   R   t   subst   _argsR   R   R   t   pointsR   R   t	   TypeError(   R   t   oR$   R%   t   parabola_eqt   it   result(    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyt   intersection   s$    G;85Dc         C  s“   |  j  j d k rR |  j j d } | |  j j d k  rE |  j } q |  j } n= |  j j d } | |  j j d k r† |  j } n	 |  j } | S(   s	  P is a parameter of parabola.

        Returns
        =======

        p : number or symbolic expression

        Notes
        =====

        The absolute value of p is the focal length. The sign on p tells
        which way the parabola faces. Vertical parabolas that open up
        and horizontal that open right, give a positive value for p.
        Vertical parabolas that open down and horizontal that open left,
        give a negative value for p.


        See Also
        ========

        http://www.sparknotes.com/math/precalc/conicsections/section2.rhtml

        Examples
        ========

        >>> from sympy import Parabola, Point, Line
        >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8)))
        >>> p1.p_parameter
        -4

        i    i   i   (   R!   R   R   t   coefficientsR   R"   R.   (   R   R$   t   pR%   (    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyR(   R  s    !	c         C  sj   |  j  } |  j j d k rB t | j d |  j | j d ƒ } n$ t | j d | j d |  j ƒ } | S(   sp  The vertex of the parabola.

        Returns
        =======

        vertex : Point

        See Also
        ========

        sympy.geometry.point.Point

        Examples
        ========

        >>> from sympy import Parabola, Point, Line
        >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8)))
        >>> p1.vertex
        Point2D(0, 4)

        i    i   (   R   R!   R   R
   R"   R(   (   R   R   R)   (    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyR)   ‚  s
    	'$N(   t   __name__t
   __module__t   __doc__t   NoneR   t   propertyR   R!   R   R#   R,   R.   R   R9   R(   R)   (    (    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyR      s   +#'#	20N(   R>   t
   __future__R    R   t
   sympy.coreR   t   sympy.core.compatibilityR   t   sympy.core.symbolR   t   sympyR   R   R   t   sympy.geometry.entityR   R	   t   sympy.geometry.pointR
   R   t   sympy.geometry.lineR   R   R   R   R   t   sympy.geometry.ellipseR   R   (    (    (    s6   lib/python2.7/site-packages/sympy/geometry/parabola.pyt   <module>   s   (