ó
¡¼™\c           @  sÂ   d  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 d d l m Z d d l m Z m Z d d	 l m Z d d
 l m Z d e f d „  ƒ  YZ d S(   sC   Curves in 2-dimensional Euclidean space.

Contains
========
Curve

iÿÿÿÿ(   t   divisiont   print_function(   t   sqrt(   t   sympifyt   diff(   t   is_sequence(   t   Tuple(   t   _symbol(   t   GeometryEntityt   GeometrySet(   t   Point(   t	   integratet   Curvec           B  sÂ   e  Z d  Z d „  Z d „  Z d d „ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d	 „  ƒ Z e d
 „  ƒ Z d d „ Z d d d „ Z d d d d „ Z d d d „ Z RS(   sU  A curve in space.

    A curve is defined by parametric functions for the coordinates, a
    parameter and the lower and upper bounds for the parameter value.

    Parameters
    ==========

    function : list of functions
    limits : 3-tuple
        Function parameter and lower and upper bounds.

    Attributes
    ==========

    functions
    parameter
    limits

    Raises
    ======

    ValueError
        When `functions` are specified incorrectly.
        When `limits` are specified incorrectly.

    See Also
    ========

    sympy.core.function.Function
    sympy.polys.polyfuncs.interpolate

    Examples
    ========

    >>> from sympy import sin, cos, Symbol, interpolate
    >>> from sympy.abc import t, a
    >>> from sympy.geometry import Curve
    >>> C = Curve((sin(t), cos(t)), (t, 0, 2))
    >>> C.functions
    (sin(t), cos(t))
    >>> C.limits
    (t, 0, 2)
    >>> C.parameter
    t
    >>> C = Curve((t, interpolate([1, 4, 9, 16], t)), (t, 0, 1)); C
    Curve((t, t**2), (t, 0, 1))
    >>> C.subs(t, 4)
    Point2D(4, 16)
    >>> C.arbitrary_point(a)
    Point2D(a, a**2)
    c         C  s›   t  | ƒ } t | ƒ s+ t | ƒ d k rD t d t | ƒ ƒ ‚ n  t | ƒ sc t | ƒ d k r| t d t | ƒ ƒ ‚ n  t j |  t | Œ  t | Œ  ƒ S(   Ni   s3   Function argument should be (x(t), y(t)) but got %si   s3   Limit argument should be (t, tmin, tmax) but got %s(   R   R   t   lent
   ValueErrort   strR   t   __new__R   (   t   clst   functiont   limitst   fun(    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyR   K   s    c         C  s?   | |  j  k r; t g  |  j D] } | j | | ƒ ^ q Œ  Sd  S(   N(   t	   parameterR
   t	   functionst   subs(   t   selft   oldt   newt   f(    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyt
   _eval_subsV   s    t   tc         C  sª   | d k r t |  j Œ  St | |  j d t ƒ} |  j } | j | j k r~ | j d „  |  j Dƒ k r~ t d | j ƒ ‚ n  t g  |  j D] } | j	 | | ƒ ^ q‹ Œ  S(   sò  
        A parameterized point on the curve.

        Parameters
        ==========

        parameter : str or Symbol, optional
            Default value is 't';
            the Curve's parameter is selected with None or self.parameter
            otherwise the provided symbol is used.

        Returns
        =======

        arbitrary_point : Point

        Raises
        ======

        ValueError
            When `parameter` already appears in the functions.

        See Also
        ========

        sympy.geometry.point.Point

        Examples
        ========

        >>> from sympy import Symbol
        >>> from sympy.abc import s
        >>> from sympy.geometry import Curve
        >>> C = Curve([2*s, s**2], (s, 0, 2))
        >>> C.arbitrary_point()
        Point2D(2*t, t**2)
        >>> C.arbitrary_point(C.parameter)
        Point2D(2*s, s**2)
        >>> C.arbitrary_point(None)
        Point2D(2*s, s**2)
        >>> C.arbitrary_point(Symbol('a'))
        Point2D(2*a, a**2)

        t   realc         s  s   |  ] } | j  Vq d  S(   N(   t   name(   t   .0R   (    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pys	   <genexpr>   s    sF   Symbol %s already appears in object and cannot be used as a parameter.N(
   t   NoneR
   R   R   R   t   TrueR   t   free_symbolsR   R   (   R   R   t   tnewR   t   w(    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyt   arbitrary_pointZ   s    -	c         C  sN   t  ƒ  } x) |  j |  j d D] } | | j O} q W| j |  j h ƒ } | S(   ss  
        Return a set of symbols other than the bound symbols used to
        parametrically define the Curve.

        Examples
        ========

        >>> from sympy.abc import t, a
        >>> from sympy.geometry import Curve
        >>> Curve((t, t**2), (t, 0, 2)).free_symbols
        set()
        >>> Curve((t, t**2), (t, a, 2)).free_symbols
        {a}
        i   (   t   setR   R   R#   t
   differenceR   (   R   t   freet   a(    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyR#   ’   s
    	c         C  s   t  |  j d ƒ S(   Ni    (   R   t   args(   R   (    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyt   ambient_dimension¨   s    c         C  s   |  j  d S(   s  The functions specifying the curve.

        Returns
        =======

        functions : list of parameterized coordinate functions.

        See Also
        ========

        parameter

        Examples
        ========

        >>> from sympy.abc import t
        >>> from sympy.geometry import Curve
        >>> C = Curve((t, t**2), (t, 0, 2))
        >>> C.functions
        (t, t**2)

        i    (   R+   (   R   (    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyR   ¬   s    c         C  s   |  j  d S(   s›  The limits for the curve.

        Returns
        =======

        limits : tuple
            Contains parameter and lower and upper limits.

        See Also
        ========

        plot_interval

        Examples
        ========

        >>> from sympy.abc import t
        >>> from sympy.geometry import Curve
        >>> C = Curve([t, t**3], (t, -2, 2))
        >>> C.limits
        (t, -2, 2)

        i   (   R+   (   R   (    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyR   Æ   s    c         C  s   |  j  d d S(   sb  The curve function variable.

        Returns
        =======

        parameter : SymPy symbol

        See Also
        ========

        functions

        Examples
        ========

        >>> from sympy.abc import t
        >>> from sympy.geometry import Curve
        >>> C = Curve([t, t**2], (t, 0, 2))
        >>> C.parameter
        t

        i   i    (   R+   (   R   (    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyR   á   s    c           s5   t  t ‡  f d †  ˆ  j Dƒ ƒ ƒ } t | ˆ  j ƒ S(   sø   The curve length.

        Examples
        ========

        >>> from sympy.geometry.curve import Curve
        >>> from sympy import cos, sin
        >>> from sympy.abc import t
        >>> Curve((t, t), (t, 0, 1)).length
        sqrt(2)
        c         3  s)   |  ] } t  | ˆ  j d  ƒ d Vq d S(   i    i   N(   R   R   (   R    t   func(   R   (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pys	   <genexpr>  s    (   R   t   sumR   R   R   (   R   t	   integrand(    (   R   s3   lib/python2.7/site-packages/sympy/geometry/curve.pyt   lengthû   s    %c         C  s0   t  | |  j d t ƒ} | g t |  j d ƒ S(   sà  The plot interval for the default geometric plot of the curve.

        Parameters
        ==========

        parameter : str or Symbol, optional
            Default value is 't';
            otherwise the provided symbol is used.

        Returns
        =======

        plot_interval : list (plot interval)
            [parameter, lower_bound, upper_bound]

        See Also
        ========

        limits : Returns limits of the parameter interval

        Examples
        ========

        >>> from sympy import Curve, sin
        >>> from sympy.abc import x, t, s
        >>> Curve((x, sin(x)), (x, 1, 2)).plot_interval()
        [t, 1, 2]
        >>> Curve((x, sin(x)), (x, 1, 2)).plot_interval(s)
        [s, 1, 2]

        R   i   (   R   R   R"   t   listR   (   R   R   R   (    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyt   plot_interval  s     i    c         C  sç   d d l  m } m } | r2 t | d d ƒ} n t d d ƒ } |  j | j Œ  } t | j ƒ } | j d ƒ | d d | ƒ } | | | ƒ 9} |  j	 | d d d … f j
 ƒ  d |  j ƒ } | d k	 rã | } | j | j Œ  S| S(	   sj  Rotate ``angle`` radians counterclockwise about Point ``pt``.

        The default pt is the origin, Point(0, 0).

        Examples
        ========

        >>> from sympy.geometry.curve import Curve
        >>> from sympy.abc import x
        >>> from sympy import pi
        >>> Curve((x, x), (x, 0, 1)).rotate(pi/2)
        Curve((-x, x), (x, 0, 1))
        iÿÿÿÿ(   t   Matrixt	   rot_axis3t   dimi   i    i   i   N(   t   sympy.matricesR3   R4   R
   t	   translateR+   R1   R   t   appendR-   t   tolistR   R!   (   R   t   anglet   ptR3   R4   t   rvR   (    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyt   rotate.  s    /i   c         C  sq   | rA t  | d d ƒ} |  j | j Œ  j | | ƒ j | j Œ  S|  j \ } } |  j | | | | f |  j ƒ S(   s9  Override GeometryEntity.scale since Curve is not made up of Points.

        Examples
        ========

        >>> from sympy.geometry.curve import Curve
        >>> from sympy import pi
        >>> from sympy.abc import x
        >>> Curve((x, x), (x, 0, 1)).scale(2)
        Curve((2*x, x), (x, 0, 1))
        R5   i   (   R
   R7   R+   t   scaleR   R-   R   (   R   t   xt   yR;   t   fxt   fy(    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyR>   L  s
    )c         C  s0   |  j  \ } } |  j | | | | f |  j ƒ S(   s!  Translate the Curve by (x, y).

        Examples
        ========

        >>> from sympy.geometry.curve import Curve
        >>> from sympy import pi
        >>> from sympy.abc import x
        >>> Curve((x, x), (x, 0, 1)).translate(1, 2)
        Curve((x + 1, x + 2), (x, 0, 1))
        (   R   R-   R   (   R   R?   R@   RA   RB   (    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyR7   ^  s    N(   t   __name__t
   __module__t   __doc__R   R   R&   t   propertyR#   R,   R   R   R   R0   R2   R!   R=   R>   R7   (    (    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyR      s   4		8#N(   RE   t
   __future__R    R   t   sympyR   t
   sympy.coreR   R   t   sympy.core.compatibilityR   t   sympy.core.containersR   t   sympy.core.symbolR   t   sympy.geometry.entityR   R	   t   sympy.geometry.pointR
   t   sympy.integralsR   R   (    (    (    s3   lib/python2.7/site-packages/sympy/geometry/curve.pyt   <module>   s   