ó
~9­\c           @  s¨  d  Z  d d l m Z m Z d d l Z d d l m Z m Z 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 m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d d l	 m Z d d l 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, d e, f d „  ƒ  YZ- d e- f d „  ƒ  YZ. d e- f d „  ƒ  YZ/ d S(   sS  Geometrical Points.

Contains
========
Point
Point2D
Point3D

When methods of Point require 1 or more points as arguments, they
can be passed as a sequence of coordinates or Points:

>>> from sympy.geometry.point import Point
>>> Point(1, 1).is_collinear((2, 2), (3, 4))
False
>>> Point(1, 1).is_collinear(Point(2, 2), Point(3, 4))
False

iÿÿÿÿ(   t   divisiont   print_functionN(   t   St   sympifyt   Expr(   t   Number(   t   iterablet   is_sequencet   as_int(   t   Tuple(   t	   nsimplifyt   simplify(   t   GeometryError(   t   sqrt(   t   im(   t   Matrix(   t   Eq(   t   Float(   t   global_evaluate(   t   Add(   t	   FiniteSet(   t   uniq(   t
   filldedentt	   func_namet   Undecidablei   (   t   GeometryEntityt   Pointc           B  s   e  Z d  Z e Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z d$ d „ Z d „  Z d „  Z d „  Z  e d „  ƒ Z! d „  Z" e d „  ƒ Z# e d „  ƒ Z$ d „  Z% e d „  ƒ Z& e d „  ƒ Z' e d  „  ƒ Z( d! „  Z) d" „  Z* e d# „  ƒ Z+ e Z, e	 Z- RS(%   sâ  A point in a n-dimensional Euclidean space.

    Parameters
    ==========

    coords : sequence of n-coordinate values. In the special
        case where n=2 or 3, a Point2D or Point3D will be created
        as appropriate.
    evaluate : if `True` (default), all floats are turn into
        exact types.
    dim : number of coordinates the point should have.  If coordinates
        are unspecified, they are padded with zeros.
    on_morph : indicates what should happen when the number of
        coordinates of a point need to be changed by adding or
        removing zeros.  Possible values are `'warn'`, `'error'`, or
        `ignore` (default).  No warning or error is given when `*args`
        is empty and `dim` is given. An error is always raised when
        trying to remove nonzero coordinates.


    Attributes
    ==========

    length
    origin: A `Point` representing the origin of the
        appropriately-dimensioned space.

    Raises
    ======

    TypeError : When instantiating with anything but a Point or sequence
    ValueError : when instantiating with a sequence with length < 2 or
        when trying to reduce dimensions if keyword `on_morph='error'` is
        set.

    See Also
    ========

    sympy.geometry.line.Segment : Connects two Points

    Examples
    ========

    >>> from sympy.geometry import Point
    >>> from sympy.abc import x
    >>> Point(1, 2, 3)
    Point3D(1, 2, 3)
    >>> Point([1, 2])
    Point2D(1, 2)
    >>> Point(0, x)
    Point2D(0, x)
    >>> Point(dim=4)
    Point(0, 0, 0, 0)

    Floats are automatically converted to Rational unless the
    evaluate flag is False:

    >>> Point(0.5, 0.25)
    Point2D(1/2, 1/4)
    >>> Point(0.5, 0.25, evaluate=False)
    Point2D(0.5, 0.25)

    c   	   
   O  s  | j  d t d ƒ } | j  d d ƒ } t | ƒ d k rD | d n | } t | t ƒ rŠ t } t | ƒ | j  d t | ƒ ƒ k rŠ | Sn  t | ƒ sº t t d j	 t
 | ƒ ƒ ƒ ƒ ‚ n  t | ƒ d k rú | j  d d  ƒ rú t j f | j  d ƒ } n  t | Œ  } | j  d t | ƒ ƒ } t | ƒ d k  rEt t d	 ƒ ƒ ‚ n  t | ƒ | k rÍd
 j	 | t | ƒ | ƒ } | d k rqÍ| d k rœt | ƒ ‚ qÍ| d k r¸t j | ƒ qÍt t d ƒ ƒ ‚ n  t d „  | | Dƒ ƒ röt d ƒ ‚ n  t d „  | Dƒ ƒ rt d ƒ ‚ n  t d „  | Dƒ ƒ s@t d ƒ ‚ n  | |  t j f | t | ƒ } | r´| j t g  | j t ƒ D]$ } | t t | d t ƒƒ f ^ qƒ ƒ } n  t | ƒ d k rÝt | d <t | | Ž  St | ƒ d k rt | d <t | | Ž  St j |  | Œ S(   Nt   evaluatei    t   on_morpht   ignorei   t   dims<   
                Expecting sequence of coordinates, not `{}`i   s[   
                Point requires 2 or more coordinates or
                keyword `dim` > 1.s1   Dimension of {} needs to be changedfrom {} to {}.t   errort   warnsf   
                        on_morph value should be 'error',
                        'warn' or 'ignore'.c         s  s   |  ] } | Vq d  S(   N(    (   t   .0t   i(    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>›   s    s&   Nonzero coordinates cannot be removed.c         s  s$   |  ] } | j  o t | ƒ Vq d  S(   N(   t	   is_numberR   (   R!   t   a(    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>   s    s(   Imaginary coordinates are not permitted.c         s  s   |  ] } t  | t ƒ Vq d  S(   N(   t
   isinstanceR   (   R!   R$   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>Ÿ   s    s,   Coordinates must be valid SymPy expressions.t   rationalt   _nochecki   (   t   getR   t   lenR%   R   t   FalseR   t	   TypeErrorR   t   formatR   t   NoneR   t   ZeroR	   t
   ValueErrort   warningsR    t   anyt   allt   xreplacet   dictt   atomsR   R   R
   t   Truet   Point2Dt   Point3DR   t   __new__(	   t   clst   argst   kwargsR   R   t   coordsR   t   messaget   f(    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR9   o   s^    "$$"	@

c         C  s)   t  d g t |  ƒ ƒ } t  j | |  ƒ S(   s7   Returns the distance between this point and the origin.i    (   R   R)   t   distance(   t   selft   origin(    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __abs__·   s    c         C  s“   y( t  j |  t  | d t ƒƒ \ } } Wn& t k
 rP t d j | ƒ ƒ ‚ n Xg  t | | ƒ D] \ } } t | | ƒ ^ qa } t  | d t ƒS(   sG  Add other to self by incrementing self's coordinates by
        those of other.

        Notes
        =====

        >>> from sympy.geometry.point import Point

        When sequences of coordinates are passed to Point methods, they
        are converted to a Point internally. This __add__ method does
        not do that so if floating point values are used, a floating
        point result (in terms of SymPy Floats) will be returned.

        >>> Point(1, 2) + (.1, .2)
        Point2D(1.1, 2.2)

        If this is not desired, the `translate` method can be used or
        another Point can be added:

        >>> Point(1, 2).translate(.1, .2)
        Point2D(11/10, 11/5)
        >>> Point(1, 2) + Point(.1, .2)
        Point2D(11/10, 11/5)

        See Also
        ========

        sympy.geometry.point.Point.translate

        R   s+   Don't know how to add {} and a Point object(   R   t   _normalize_dimensionR*   R+   R   R,   t   zipR   (   RA   t   othert   st   oR$   t   bR=   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __add__¼   s    (2c         C  s   | |  j  k S(   N(   R;   (   RA   t   item(    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __contains__ã   s    c         C  sB   t  | ƒ } g  |  j D] } t | | ƒ ^ q } t | d t ƒS(   s'   Divide point's coordinates by a factor.R   (   R   R;   R   R   R*   (   RA   t   divisort   xR=   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __div__æ   s    &c         C  sB   t  | t ƒ s. t |  j ƒ t | j ƒ k r2 t S|  j | j k S(   N(   R%   R   R)   R;   R*   (   RA   RF   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __eq__ì   s    .c         C  s   |  j  | S(   N(   R;   (   RA   t   key(    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __getitem__ñ   s    c         C  s   t  |  j ƒ S(   N(   t   hashR;   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __hash__ô   s    c         C  s   |  j  j ƒ  S(   N(   R;   t   __iter__(   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRU   ÷   s    c         C  s   t  |  j ƒ S(   N(   R)   R;   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __len__ú   s    c         C  sB   t  | ƒ } g  |  j D] } t | | ƒ ^ q } t | d t ƒS(   s{  Multiply point's coordinates by a factor.

        Notes
        =====

        >>> from sympy.geometry.point import Point

        When multiplying a Point by a floating point number,
        the coordinates of the Point will be changed to Floats:

        >>> Point(1, 2)*0.1
        Point2D(0.1, 0.2)

        If this is not desired, the `scale` method can be used or
        else only multiply or divide by integers:

        >>> Point(1, 2).scale(1.1, 1.1)
        Point2D(11/10, 11/5)
        >>> Point(1, 2)*11/10
        Point2D(11/10, 11/5)

        See Also
        ========

        sympy.geometry.point.Point.scale
        R   (   R   R;   R   R   R*   (   RA   t   factorRN   R=   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __mul__ý   s    &c         C  s-   g  |  j  D] } | ^ q
 } t | d t ƒS(   s   Negate the point.R   (   R;   R   R*   (   RA   RN   R=   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __neg__  s    c         C  s   |  g  | D] } | ^ q
 S(   sP   Subtract two points, or subtract a factor from this point's
        coordinates.(    (   RA   RF   RN   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   __sub__!  s    c           s¯   t  |  d d ƒ ‰  | j d ˆ  ƒ ‰  ˆ  d k rI t d „  | Dƒ ƒ ‰  n  t ‡  f d †  | Dƒ ƒ ro t | ƒ Sˆ  | d <| j d d ƒ | d <g  | D] } t | |  ^ q– S(   s~   Ensure that points have the same dimension.
        By default `on_morph='warn'` is passed to the
        `Point` constructor.t   _ambient_dimensionR   c         s  s   |  ] } | j  Vq d  S(   N(   t   ambient_dimension(   R!   R"   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>1  s    c         3  s   |  ] } | j  ˆ  k Vq d  S(   N(   R\   (   R!   R"   (   R   (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>2  s    R   R    N(   t   getattrR-   R(   t   maxR2   t   listR   (   R:   t   pointsR<   R"   (    (   R   s3   lib/python2.7/site-packages/sympy/geometry/point.pyRD   &  s    

c          G  s•   t  |  ƒ d k r d St j g  |  D] } t | ƒ ^ q# Œ  } | d } g  | d D] } | | ^ qS } t g  | D] } | j ^ qs ƒ } | j ƒ  S(   sg  The affine rank of a set of points is the dimension
        of the smallest affine space containing all the points.
        For example, if the points lie on a line (and are not all
        the same) their affine rank is 1.  If the points lie on a plane
        but not a line, their affine rank is 2.  By convention, the empty
        set has affine rank -1.i    iÿÿÿÿi   (   R)   R   RD   R   R;   t   rank(   R;   R"   R`   RB   t   m(    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   affine_rank8  s    	(
!"c         C  s   t  |  d t |  ƒ ƒ S(   s$   Number of components this point has.R[   (   R]   R)   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR\   L  s    c         G  sz   t  | ƒ d k r t S|  j g  | D] } t | ƒ ^ q# Œ  } | d j d k rU t St t | ƒ ƒ } t j | Œ  d k S(   sñ  Return True if there exists a plane in which all the points
        lie.  A trivial True value is returned if `len(points) < 3` or
        all Points are 2-dimensional.

        Parameters
        ==========

        A set of points

        Raises
        ======

        ValueError : if less than 3 unique points are given

        Returns
        =======

        boolean

        Examples
        ========

        >>> from sympy import Point3D
        >>> p1 = Point3D(1, 2, 2)
        >>> p2 = Point3D(2, 7, 2)
        >>> p3 = Point3D(0, 0, 2)
        >>> p4 = Point3D(1, 1, 2)
        >>> Point3D.are_coplanar(p1, p2, p3, p4)
        True
        >>> p5 = Point3D(0, 1, 3)
        >>> Point3D.are_coplanar(p1, p2, p3, p5)
        False

        i   i    i   (   R)   R6   RD   R   R\   R_   R   Rc   (   R:   R`   R"   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   are_coplanarQ  s    $(c         C  sæ   t  | t ƒ sU y t | d |  j ƒ} WqU t k
 rQ t d t | ƒ ƒ ‚ qU Xn  t  | t ƒ r¥ t j |  t | ƒ ƒ \ } } t t d „  t	 | | ƒ Dƒ Œ  ƒ St
 | d d ƒ } | d k rÜ t d t | ƒ ƒ ‚ n  | |  ƒ S(   sƒ  The Euclidean distance between self and another GeometricEntity.

        Returns
        =======

        distance : number or symbolic expression.

        Raises
        ======

        TypeError : if other is not recognized as a GeometricEntity or is a
                    GeometricEntity for which distance is not defined.

        See Also
        ========

        sympy.geometry.line.Segment.length
        sympy.geometry.point.Point.taxicab_distance

        Examples
        ========

        >>> from sympy.geometry import Point, Line
        >>> p1, p2 = Point(1, 1), Point(4, 5)
        >>> l = Line((3, 1), (2, 2))
        >>> p1.distance(p2)
        5
        >>> p1.distance(l)
        sqrt(2)

        The computed distance may be symbolic, too:

        >>> from sympy.abc import x, y
        >>> p3 = Point(x, y)
        >>> p3.distance((0, 0))
        sqrt(x**2 + y**2)

        R   s'   not recognized as a GeometricEntity: %sc         s  s#   |  ] \ } } | | d  Vq d S(   i   N(    (   R!   R$   RI   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>­  s    R@   s,   distance between Point and %s is not definedN(   R%   R   R   R\   R+   t   typeRD   R   R   RE   R]   R-   (   RA   RF   RG   t   pR@   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR@     s    '#c         C  s8   t  | ƒ s t | ƒ } n  t d „  t |  | ƒ Dƒ Œ  S(   s.   Return dot product of self with another Point.c         s  s   |  ] \ } } | | Vq d  S(   N(    (   R!   R$   RI   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>·  s    (   R   R   R   RE   (   RA   Rf   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   dot³  s    c         C  sI   t  | t ƒ s( t |  ƒ t | ƒ k r, t St d „  t |  | ƒ Dƒ ƒ S(   s8   Returns whether the coordinates of self and other agree.c         s  s$   |  ] \ } } | j  | ƒ Vq d  S(   N(   t   equals(   R!   R$   RI   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>¾  s    (   R%   R   R)   R*   R2   RE   (   RA   RF   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRh   ¹  s    (c         K  s8   g  |  j  D] } | j | |  ^ q
 } t d t | Œ S(   sF  Evaluate the coordinates of the point.

        This method will, where possible, create and return a new Point
        where the coordinates are evaluated as floating point numbers to
        the precision indicated (default=15).

        Parameters
        ==========

        prec : int

        Returns
        =======

        point : Point

        Examples
        ========

        >>> from sympy import Point, Rational
        >>> p1 = Point(Rational(1, 2), Rational(3, 2))
        >>> p1
        Point2D(1/2, 3/2)
        >>> p1.evalf()
        Point2D(0.5, 1.5)

        R   (   R;   t   evalfR   R*   (   RA   t   prect   optionsRN   R=   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRi   À  s    (c         C  sˆ   t  | t ƒ s t | ƒ } n  t  | t ƒ r{ |  | k r@ |  g St j |  | ƒ \ } } | |  k rw | | k rw |  g Sg  S| j |  ƒ S(   sX  The intersection between this point and another GeometryEntity.

        Parameters
        ==========

        other : Point

        Returns
        =======

        intersection : list of Points

        Notes
        =====

        The return value will either be an empty list if there is no
        intersection, otherwise it will contain this point.

        Examples
        ========

        >>> from sympy import Point
        >>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(0, 0)
        >>> p1.intersection(p2)
        []
        >>> p1.intersection(p3)
        [Point2D(0, 0)]

        (   R%   R   R   RD   t   intersection(   RA   RF   t   p1t   p2(    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRl   ß  s    c         G  sZ   |  f | } t  j g  | D] } t  | ƒ ^ q Œ  } t t | ƒ ƒ } t  j | Œ  d k S(   sÛ  Returns `True` if there exists a line
        that contains `self` and `points`.  Returns `False` otherwise.
        A trivially True value is returned if no points are given.

        Parameters
        ==========

        args : sequence of Points

        Returns
        =======

        is_collinear : boolean

        See Also
        ========

        sympy.geometry.line.Line

        Examples
        ========

        >>> from sympy import Point
        >>> from sympy.abc import x
        >>> p1, p2 = Point(0, 0), Point(1, 1)
        >>> p3, p4, p5 = Point(2, 2), Point(x, x), Point(1, 2)
        >>> Point.is_collinear(p1, p2, p3, p4)
        True
        >>> Point.is_collinear(p1, p2, p3, p5)
        False

        i   (   R   RD   R_   R   Rc   (   RA   R;   R`   R"   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   is_collinear  s    !(c   	      G  sè   |  f | } t  j g  | D] } t  | ƒ ^ q Œ  } t t | ƒ ƒ } t  j | Œ  d k s` t S| d } g  | D] } | | ^ qq } t g  | D]" } t | ƒ | j | ƒ g ^ q‘ ƒ } | j ƒ  \ } } t	 | ƒ | k rä t
 St S(   s  Do `self` and the given sequence of points lie in a circle?

        Returns True if the set of points are concyclic and
        False otherwise. A trivial value of True is returned
        if there are fewer than 2 other points.

        Parameters
        ==========

        args : sequence of Points

        Returns
        =======

        is_concyclic : boolean


        Examples
        ========

        >>> from sympy import Point

        Define 4 points that are on the unit circle:

        >>> p1, p2, p3, p4 = Point(1, 0), (0, 1), (-1, 0), (0, -1)

        >>> p1.is_concyclic() == p1.is_concyclic(p2, p3, p4) == True
        True

        Define a point not on that circle:

        >>> p = Point(1, 1)

        >>> p.is_concyclic(p1, p2, p3)
        False

        i   i    (   R   RD   R_   R   Rc   R*   R   Rg   t   rrefR)   R6   (	   RA   R;   R`   R"   RB   Rf   t   matRp   t   pivots(    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   is_concyclic.  s    &(
5c         C  s   |  j  } | d k r d S| S(   sr   True if any coordinate is nonzero, False if every coordinate is zero,
        and None if it cannot be determined.N(   t   is_zeroR-   (   RA   Rt   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt
   is_nonzerof  s    	c   
      C  s½   t  j |  t  | ƒ ƒ \ } } | j d k r• | j | j \ } } \ } } | | | | j d ƒ } | d k r• t t d | | f ƒ ƒ ‚ q• n  t | j | j g ƒ }	 |	 j	 ƒ  d k  S(   s{   Returns whether each coordinate of `self` is a scalar
        multiple of the corresponding coordinate in point p.
        i   i    sD   can't determine if %s is a scalar multiple of
                    %sN(
   R   RD   R\   R;   Rh   R-   R   R   R   Ra   (
   RA   Rf   RG   RH   t   x1t   y1t   x2t   y2t   rvRb   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   is_scalar_multipleo  s    c         C  sM   g  |  j  D] } | j ^ q
 } t | ƒ r/ t St d „  | Dƒ ƒ rI d St S(   ss   True if every coordinate is zero, False if any coordinate is not zero,
        and None if it cannot be determined.c         s  s   |  ] } | d  k Vq d  S(   N(   R-   (   R!   RN   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>‰  s    N(   R;   Ru   R1   R*   R-   R6   (   RA   RN   t   nonzero(    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRt   ‚  s    c         C  s   t  j S(   sÚ   
        Treating a Point as a Line, this returns 0 for the length of a Point.

        Examples
        ========

        >>> from sympy import Point
        >>> p = Point(0, 1)
        >>> p.length
        0
        (   R   R.   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   length  s    c         C  s[   t  j |  t  | ƒ ƒ \ } } t  g  t | | ƒ D]# \ } } t | | t j ƒ ^ q1 ƒ S(   s¨  The midpoint between self and point p.

        Parameters
        ==========

        p : Point

        Returns
        =======

        midpoint : Point

        See Also
        ========

        sympy.geometry.line.Segment.midpoint

        Examples
        ========

        >>> from sympy.geometry import Point
        >>> p1, p2 = Point(1, 1), Point(13, 5)
        >>> p1.midpoint(p2)
        Point2D(7, 3)

        (   R   RD   RE   R   R   t   Half(   RA   Rf   RG   R$   RI   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   midpointœ  s    c         C  s   t  d g t |  ƒ d t ƒS(   sO   A point of all zeros of the same ambient dimension
        as the current pointi    R   (   R   R)   R*   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRB   º  s    c         C  s’   |  j  } |  d t j k r8 t d g | d d g ƒ S|  d t j k rj t d d g | d d g ƒ St |  d |  d g | d d g ƒ S(   s~  Returns a non-zero point that is orthogonal to the
        line containing `self` and the origin.

        Examples
        ========

        >>> from sympy.geometry import Line, Point
        >>> a = Point(1, 2, 3)
        >>> a.orthogonal_direction
        Point3D(-2, 1, 0)
        >>> b = _
        >>> Line(b, b.origin).is_perpendicular(Line(a, a.origin))
        True
        i    i   i   (   R\   R   R.   R   (   RA   R   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   orthogonal_directionÀ  s    	c         C  sZ   t  j t  |  ƒ t  | ƒ ƒ \ }  } | j r< t d ƒ ‚ n  | |  j | ƒ | j | ƒ S(   s‹  Project the point `a` onto the line between the origin
        and point `b` along the normal direction.

        Parameters
        ==========

        a : Point
        b : Point

        Returns
        =======

        p : Point

        See Also
        ========

        sympy.geometry.line.LinearEntity.projection

        Examples
        ========

        >>> from sympy.geometry import Line, Point
        >>> a = Point(1, 2)
        >>> b = Point(2, 5)
        >>> z = a.origin
        >>> p = Point.project(a, b)
        >>> Line(p, a).is_perpendicular(Line(p, b))
        True
        >>> Point.is_collinear(z, p, b)
        True
        s"   Cannot project to the zero vector.(   R   RD   Rt   R/   Rg   (   R$   RI   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   projectÚ  s    "$	c         C  s;   t  j |  t  | ƒ ƒ \ } } t d „  t | | ƒ Dƒ Œ  S(   s;  The Taxicab Distance from self to point p.

        Returns the sum of the horizontal and vertical distances to point p.

        Parameters
        ==========

        p : Point

        Returns
        =======

        taxicab_distance : The sum of the horizontal
        and vertical distances to point p.

        See Also
        ========

        sympy.geometry.point.Point.distance

        Examples
        ========

        >>> from sympy.geometry import Point
        >>> p1, p2 = Point(1, 1), Point(4, 5)
        >>> p1.taxicab_distance(p2)
        7

        c         s  s%   |  ] \ } } t  | | ƒ Vq d  S(   N(   t   abs(   R!   R$   RI   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>   s    (   R   RD   R   RE   (   RA   Rf   RG   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   taxicab_distance  s    c         C  s\   t  j |  t  | ƒ ƒ \ } } |  j r? | j r? t d ƒ ‚ n  t d „  t | | ƒ Dƒ Œ  S(   s–  The Canberra Distance from self to point p.

        Returns the weighted sum of horizontal and vertical distances to
        point p.

        Parameters
        ==========

        p : Point

        Returns
        =======

        canberra_distance : The weighted sum of horizontal and vertical
        distances to point p. The weight used is the sum of absolute values
        of the coordinates.

        See Also
        ========

        sympy.geometry.point.Point.distance

        Examples
        ========

        >>> from sympy.geometry import Point
        >>> p1, p2 = Point(1, 1), Point(3, 3)
        >>> p1.canberra_distance(p2)
        1
        >>> p1, p2 = Point(0, 0), Point(3, 3)
        >>> p1.canberra_distance(p2)
        2

        Raises
        ======

        ValueError when both vectors are zero.

        See Also
        ========

        sympy.geometry.point.Point.distance

        s"   Cannot project to the zero vector.c         s  s9   |  ]/ \ } } t  | | ƒ t  | ƒ t  | ƒ Vq d  S(   N(   R‚   (   R!   R$   RI   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>S  s    (   R   RD   Rt   R/   R   RE   (   RA   Rf   RG   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   canberra_distance"  s    .c         C  s   |  t  |  ƒ S(   sd   Return the Point that is in the same direction as `self`
        and a distance of 1 from the origin(   R‚   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   unitU  s    N(.   t   __name__t
   __module__t   __doc__R6   t   is_PointR9   RC   RJ   RL   RO   RP   RR   RT   RU   RV   RX   RY   RZ   t   classmethodRD   t   staticmethodRc   t   propertyR\   Rd   R@   Rg   Rh   R-   Ri   Rl   Ro   Rs   Ru   R{   Rt   R}   R   RB   R€   R   Rƒ   R„   R…   t   nt   __truediv__(    (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR   ,   sN   ?	H		'										.	4			)	&	8			'	!	3R7   c           B  s‰   e  Z d  Z d Z d „  Z d „  Z e d „  ƒ Z d d „ Z	 d d d d „ Z
 d „  Z d	 d	 d
 „ Z e d „  ƒ Z e d „  ƒ Z RS(   s²  A point in a 2-dimensional Euclidean space.

    Parameters
    ==========

    coords : sequence of 2 coordinate values.

    Attributes
    ==========

    x
    y
    length

    Raises
    ======

    TypeError
        When trying to add or subtract points with different dimensions.
        When trying to create a point with more than two dimensions.
        When `intersection` is called with object other than a Point.

    See Also
    ========

    sympy.geometry.line.Segment : Connects two Points

    Examples
    ========

    >>> from sympy.geometry import Point2D
    >>> from sympy.abc import x
    >>> Point2D(1, 2)
    Point2D(1, 2)
    >>> Point2D([1, 2])
    Point2D(1, 2)
    >>> Point2D(0, x)
    Point2D(0, x)

    Floats are automatically converted to Rational unless the
    evaluate flag is False:

    >>> Point2D(0.5, 0.25)
    Point2D(1/2, 1/4)
    >>> Point2D(0.5, 0.25, evaluate=False)
    Point2D(0.5, 0.25)

    i   c         O  s>   | j  d t ƒ s. d | d <t | | Ž  } n  t j |  | Œ S(   NR'   i   R   (   t   popR*   R   R   R9   (   R:   R;   R<   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR9   “  s    
c         C  s
   | |  k S(   N(    (   RA   RK   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRL   ™  s    c         C  s   |  j  |  j |  j  |  j f S(   sw   Return a tuple (xmin, ymin, xmax, ymax) representing the bounding
        rectangle for the geometric figure.

        (   RN   t   y(   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   boundsœ  s    c         C  s¸   d d l  m } m } m } | | ƒ } | | ƒ } |  } | d k	 re | | d d ƒ} | | 8} n  | j \ }	 }
 | | |	 | |
 | |	 | |
 ƒ } | d k	 r´ | | 7} n  | S(   sX  Rotate ``angle`` radians counterclockwise about Point ``pt``.

        See Also
        ========

        rotate, scale

        Examples
        ========

        >>> from sympy import Point2D, pi
        >>> t = Point2D(1, 0)
        >>> t.rotate(pi/2)
        Point2D(0, 1)
        >>> t.rotate(pi/2, (2, 0))
        Point2D(2, -1)

        iÿÿÿÿ(   t   cost   sinR   R   i   N(   t   sympyR’   R“   R   R-   R;   (   RA   t   anglet   ptR’   R“   R   t   cRG   Rz   RN   R   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   rotate¥  s    'i   c         C  s\   | rA t  | d d ƒ} |  j | j Œ  j | | ƒ j | j Œ  St  |  j | |  j | ƒ S(   sõ  Scale the coordinates of the Point by multiplying by
        ``x`` and ``y`` after subtracting ``pt`` -- default is (0, 0) --
        and then adding ``pt`` back again (i.e. ``pt`` is the point of
        reference for the scaling).

        See Also
        ========

        rotate, translate

        Examples
        ========

        >>> from sympy import Point2D
        >>> t = Point2D(1, 1)
        >>> t.scale(2)
        Point2D(2, 1)
        >>> t.scale(2, 2)
        Point2D(2, 2)

        R   i   (   R   t	   translateR;   t   scaleRN   R   (   RA   RN   R   R–   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRš   Ç  s    )c         C  s‹   | j  o | j d k s' t d ƒ ‚ n  | j \ } } | j oH | d k } |  j \ } } t t d d | | d g ƒ | j ƒ  d d  Œ  S(   sî   Return the point after applying the transformation described
        by the 3x3 Matrix, ``matrix``.

        See Also
        ========
        geometry.entity.rotate
        geometry.entity.scale
        geometry.entity.translate
        i   s   matrix must be a 3x3 matrixi   i    i   (   i   i   (   t	   is_Matrixt   shapeR/   t	   is_squareR;   R   R   t   tolist(   RA   t   matrixt   colt   rowt   valid_matrixRN   R   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt	   transformâ  s    
i    c         C  s   t  |  j | |  j | ƒ S(   s‡  Shift the Point by adding x and y to the coordinates of the Point.

        See Also
        ========

        rotate, scale

        Examples
        ========

        >>> from sympy import Point2D
        >>> t = Point2D(0, 1)
        >>> t.translate(2)
        Point2D(2, 1)
        >>> t.translate(2, 2)
        Point2D(2, 3)
        >>> t + Point2D(2, 2)
        Point2D(2, 3)

        (   R   RN   R   (   RA   RN   R   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR™   ô  s    c         C  s   |  j  d S(   sº   
        Returns the X coordinate of the Point.

        Examples
        ========

        >>> from sympy import Point2D
        >>> p = Point2D(0, 1)
        >>> p.x
        0
        i    (   R;   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRN     s    c         C  s   |  j  d S(   sº   
        Returns the Y coordinate of the Point.

        Examples
        ========

        >>> from sympy import Point2D
        >>> p = Point2D(0, 1)
        >>> p.y
        1
        i   (   R;   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR     s    N(   R†   R‡   Rˆ   R[   R9   RL   RŒ   R‘   R-   R˜   Rš   R£   R™   RN   R   (    (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR7   _  s   0			"	R8   c           B  s­   e  Z d  Z d Z d „  Z d „  Z e d „  ƒ Z d „  Z d „  Z	 d „  Z
 d d d d d	 „ Z d
 „  Z d d d d „ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z RS(   s6  A point in a 3-dimensional Euclidean space.

    Parameters
    ==========

    coords : sequence of 3 coordinate values.

    Attributes
    ==========

    x
    y
    z
    length

    Raises
    ======

    TypeError
        When trying to add or subtract points with different dimensions.
        When `intersection` is called with object other than a Point.

    Examples
    ========

    >>> from sympy import Point3D
    >>> from sympy.abc import x
    >>> Point3D(1, 2, 3)
    Point3D(1, 2, 3)
    >>> Point3D([1, 2, 3])
    Point3D(1, 2, 3)
    >>> Point3D(0, x, 3)
    Point3D(0, x, 3)

    Floats are automatically converted to Rational unless the
    evaluate flag is False:

    >>> Point3D(0.5, 0.25, 2)
    Point3D(1/2, 1/4, 2)
    >>> Point3D(0.5, 0.25, 3, evaluate=False)
    Point3D(0.5, 0.25, 3)

    i   c         O  s>   | j  d t ƒ s. d | d <t | | Ž  } n  t j |  | Œ S(   NR'   i   R   (   R   R*   R   R   R9   (   R:   R;   R<   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR9   X  s    
c         C  s
   | |  k S(   N(    (   RA   RK   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRL   ^  s    c          G  s   t  j |  Œ  S(   s  Is a sequence of points collinear?

        Test whether or not a set of points are collinear. Returns True if
        the set of points are collinear, or False otherwise.

        Parameters
        ==========

        points : sequence of Point

        Returns
        =======

        are_collinear : boolean

        See Also
        ========

        sympy.geometry.line.Line3D

        Examples
        ========

        >>> from sympy import Point3D, Matrix
        >>> from sympy.abc import x
        >>> p1, p2 = Point3D(0, 0, 0), Point3D(1, 1, 1)
        >>> p3, p4, p5 = Point3D(2, 2, 2), Point3D(x, x, x), Point3D(1, 2, 6)
        >>> Point3D.are_collinear(p1, p2, p3, p4)
        True
        >>> Point3D.are_collinear(p1, p2, p3, p5)
        False
        (   R   Ro   (   R`   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   are_collineara  s    "c         C  sb   |  j  | ƒ } t t d „  | Dƒ Œ  ƒ } | j |  j | | j |  j | | j |  j | g S(   sp  
        Gives the direction cosine between 2 points

        Parameters
        ==========

        p : Point3D

        Returns
        =======

        list

        Examples
        ========

        >>> from sympy import Point3D
        >>> p1 = Point3D(1, 2, 3)
        >>> p1.direction_cosine(Point3D(2, 3, 5))
        [sqrt(6)/6, sqrt(6)/6, sqrt(6)/3]
        c         s  s   |  ] } | d  Vq d S(   i   N(    (   R!   R"   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pys	   <genexpr>œ  s    (   t   direction_ratioR   R   RN   R   t   z(   RA   t   pointR$   RI   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   direction_cosine…  s    "c         C  s+   | j  |  j  | j |  j | j |  j g S(   sV  
        Gives the direction ratio between 2 points

        Parameters
        ==========

        p : Point3D

        Returns
        =======

        list

        Examples
        ========

        >>> from sympy import Point3D
        >>> p1 = Point3D(1, 2, 3)
        >>> p1.direction_ratio(Point3D(2, 3, 5))
        [1, 1, 2]
        (   RN   R   R¦   (   RA   R§   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR¥      s    c         C  sW   t  | t ƒ s$ t | d d ƒ} n  t  | t ƒ rJ |  | k rF |  g Sg  S| j |  ƒ S(   sc  The intersection between this point and another point.

        Parameters
        ==========

        other : Point

        Returns
        =======

        intersection : list of Points

        Notes
        =====

        The return value will either be an empty list if there is no
        intersection, otherwise it will contain this point.

        Examples
        ========

        >>> from sympy import Point3D
        >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(0, 0, 0)
        >>> p1.intersection(p2)
        []
        >>> p1.intersection(p3)
        [Point3D(0, 0, 0)]

        R   i   (   R%   R   R   R8   Rl   (   RA   RF   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRl   ¸  s    i   c         C  sc   | r> t  | ƒ } |  j | j Œ  j | | | ƒ j | j Œ  St  |  j | |  j | |  j | ƒ S(   sö  Scale the coordinates of the Point by multiplying by
        ``x`` and ``y`` after subtracting ``pt`` -- default is (0, 0) --
        and then adding ``pt`` back again (i.e. ``pt`` is the point of
        reference for the scaling).

        See Also
        ========

        translate

        Examples
        ========

        >>> from sympy import Point3D
        >>> t = Point3D(1, 1, 1)
        >>> t.scale(2)
        Point3D(2, 1, 1)
        >>> t.scale(2, 2)
        Point3D(2, 2, 1)

        (   R8   R™   R;   Rš   RN   R   R¦   (   RA   RN   R   R¦   R–   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRš   Þ  s    ,c   
      C  s­   | j  o | j d k s' t d ƒ ‚ n  | j \ } } | j oH | d k } d d l m } |  j \ } } } | | ƒ }	 t t d d | | | d g ƒ |	 j	 ƒ  d d  Œ  S(	   sî   Return the point after applying the transformation described
        by the 4x4 Matrix, ``matrix``.

        See Also
        ========
        geometry.entity.rotate
        geometry.entity.scale
        geometry.entity.translate
        i   s   matrix must be a 4x4 matrixiÿÿÿÿ(   t	   Transposei   i    i   (   i   i   (
   R›   Rœ   R/   R   t   sympy.matrices.expressionsR©   R;   R8   R   Rž   (
   RA   RŸ   R    R¡   R¢   R©   RN   R   R¦   Rb   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR£   ù  s    
i    c         C  s%   t  |  j | |  j | |  j | ƒ S(   s–  Shift the Point by adding x and y to the coordinates of the Point.

        See Also
        ========

        rotate, scale

        Examples
        ========

        >>> from sympy import Point3D
        >>> t = Point3D(0, 1, 1)
        >>> t.translate(2)
        Point3D(2, 1, 1)
        >>> t.translate(2, 2)
        Point3D(2, 3, 1)
        >>> t + Point3D(2, 2, 2)
        Point3D(2, 3, 3)

        (   R8   RN   R   R¦   (   RA   RN   R   R¦   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR™     s    c         C  s   |  j  d S(   s½   
        Returns the X coordinate of the Point.

        Examples
        ========

        >>> from sympy import Point3D
        >>> p = Point3D(0, 1, 3)
        >>> p.x
        0
        i    (   R;   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyRN   $  s    c         C  s   |  j  d S(   s½   
        Returns the Y coordinate of the Point.

        Examples
        ========

        >>> from sympy import Point3D
        >>> p = Point3D(0, 1, 2)
        >>> p.y
        1
        i   (   R;   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR   3  s    c         C  s   |  j  d S(   s½   
        Returns the Z coordinate of the Point.

        Examples
        ========

        >>> from sympy import Point3D
        >>> p = Point3D(0, 1, 1)
        >>> p.z
        1
        i   (   R;   (   RA   (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR¦   B  s    N(   R†   R‡   Rˆ   R[   R9   RL   R‹   R¤   R¨   R¥   Rl   R-   Rš   R£   R™   RŒ   RN   R   R¦   (    (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyR8   )  s   +		$			&	(0   Rˆ   t
   __future__R    R   R0   t
   sympy.coreR   R   R   t   sympy.core.numbersR   t   sympy.core.compatibilityR   R   R   t   sympy.core.containersR	   t   sympy.simplifyR
   R   t   sympy.geometry.exceptionsR   t(   sympy.functions.elementary.miscellaneousR   t$   sympy.functions.elementary.complexesR   t   sympy.matricesR   t   sympy.core.relationalR   R   t   sympy.core.evaluateR   t   sympy.core.addR   t
   sympy.setsR   t   sympy.utilities.iterablesR   t   sympy.utilities.miscR   R   R   t   entityR   R   R7   R8   (    (    (    s3   lib/python2.7/site-packages/sympy/geometry/point.pyt   <module>   s2   ÿ ÿ ÿ 6Ê