
    Ed'                         d 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 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  G d de          ZdS )zCCurves in 2-dimensional Euclidean space.

Contains
========
Curve

    )sqrt)diff)Tuple)_symbol)GeometryEntityGeometrySet)Point)	integrate)Matrix	rot_axis3)is_sequence)prec_to_dpsc                       e Zd ZdZd Zd Zd Zd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ZddZddZdS )Curvea,  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.

    Examples
    ========

    >>> from sympy import Curve, sin, cos, interpolate
    >>> from sympy.abc import t, a
    >>> 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)

    See Also
    ========

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

    c                 N   t          |          rt          |          dk    rt          dt          |          z            t          |          rt          |          dk    rt          dt          |          z            t	          j        | t          | t          |           S )N   z3Function argument should be (x(t), y(t)) but got %s   z3Limit argument should be (t, tmin, tmax) but got %s)r   len
ValueErrorstrr   __new__r   )clsfunctionlimitss      4lib/python3.11/site-packages/sympy/geometry/curve.pyr   zCurve.__new__L   s    8$$ 	.H(: 	. "8}}- . . .6"" 	,c&kkQ&6 	, "6{{+ , , , %c5(+;UF^LLL    c                 8    |                      | j        |          S N)subs	parameter)selffs     r   __call__zCurve.__call__V   s    yy+++r   c                 V    | j         k    rt          fd| j        D              S d S )Nc                 <    g | ]}|                               S  r   ).0r"   newolds     r   
<listcomp>z$Curve._eval_subs.<locals>.<listcomp>[   s'    DDD166#s++DDDr   )r    r	   	functions)r!   r*   r)   s    ``r   
_eval_subszCurve._eval_subsY   sE    $.  	FDDDDDT^DDDEE	F 	Fr      c                     | j         \  }\  }}}t          |          t          fd|D                       }fd||fD             \  }}|                     ||||f          S )Nc                 .    g | ]} |j         dd iS nr&   evalfr(   idpsoptionss     r   r+   z%Curve._eval_evalf.<locals>.<listcomp>`   s0    888717,,S,G,,888r   c                 .    g | ]} |j         dd iS r1   r3   r5   s     r   r+   z%Curve._eval_evalf.<locals>.<listcomp>a   s0    :::a))#))):::r   )argsr   tuplefunc)r!   precr8   r"   tabr7   s     `    @r   _eval_evalfzCurve._eval_evalf]   s    y9Aq!$88888a88899:::::Aq6:::1yyQ1I&&&r   r>   c                    |t          | j         S t          || j        d          | j        j        j        k    r/j        d | j        D             v rt          dj        z            t          fd| j        D              S )a  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
        =======

        Point :
            Returns a point in parametric form.

        Raises
        ======

        ValueError
            When `parameter` already appears in the functions.

        Examples
        ========

        >>> from sympy import Curve, Symbol
        >>> from sympy.abc import s
        >>> 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)

        See Also
        ========

        sympy.geometry.point.Point

        NTrealc              3   $   K   | ]}|j         V  d S r   )name)r(   r"   s     r   	<genexpr>z(Curve.arbitrary_point.<locals>.<genexpr>   s$      @@af@@@@@@r   zFSymbol %s already appears in object and cannot be used as a parameter.c                 <    g | ]}|                               S r&   r'   )r(   wr>   tnews     r   r+   z)Curve.arbitrary_point.<locals>.<listcomp>   s%    ???1qvva???r   )r	   r,   r   r    rF   free_symbolsr   )r!   r    r>   rJ   s     @@r   arbitrary_pointzCurve.arbitrary_pointd   s    X  	*$.))y$.t<<<NI 	B	@@d.?@@@@	B 57;yA B B B????????@@r   c                     t                      }| j        | j        dd         z   D ]}||j        z  }|                    | j        h          }|S )a  Return a set of symbols other than the bound symbols used to
        parametrically define the Curve.

        Returns
        =======

        set :
            Set of all non-parameterized symbols.

        Examples
        ========

        >>> from sympy.abc import t, a
        >>> from sympy import Curve
        >>> Curve((t, t**2), (t, 0, 2)).free_symbols
        set()
        >>> Curve((t, t**2), (t, a, 2)).free_symbols
        {a}

           N)setr,   r   rK   
differencer    )r!   freer?   s      r   rK   zCurve.free_symbols   sV    , uu$+abb/1 	# 	#AAN"DD/00r   c                 6    t          | j        d                   S )a;  The dimension of the curve.

        Returns
        =======

        int :
            the dimension of curve.

        Examples
        ========

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

        r   )r   r:   r!   s    r   ambient_dimensionzCurve.ambient_dimension   s    * 49Q<   r   c                     | j         d         S )a  The functions specifying the curve.

        Returns
        =======

        functions :
            list of parameterized coordinate functions.

        Examples
        ========

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

        See Also
        ========

        parameter

        r   r:   rS   s    r   r,   zCurve.functions       2 y|r   c                     | j         d         S )a  The limits for the curve.

        Returns
        =======

        limits : tuple
            Contains parameter and lower and upper limits.

        Examples
        ========

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

        See Also
        ========

        plot_interval

        rN   rV   rS   s    r   r   zCurve.limits   rW   r   c                 (    | j         d         d         S )am  The curve function variable.

        Returns
        =======

        Symbol :
            returns a bound symbol.

        Examples
        ========

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

        See Also
        ========

        functions

        rN   r   rV   rS   s    r   r    zCurve.parameter  s    2 y|Ar   c                      t          t           fd j        D                                 }t          | j                  S )zThe curve length.

        Examples
        ========

        >>> from sympy import Curve
        >>> from sympy.abc import t
        >>> Curve((t, t), (t, 0, 1)).length
        sqrt(2)

        c              3   T   K   | ]"}t          |j        d                    dz  V  #dS )r   r   N)r   r   )r(   r<   r!   s     r   rG   zCurve.length.<locals>.<genexpr>,  s8      VVtT$A77:VVVVVVr   )r   sumr,   r
   r   )r!   	integrands   ` r   lengthzCurve.length  sC     VVVVt~VVVVVWW	DK000r   c                 p    t          || j        d          }|gt          | j        dd                   z   S )a  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
        =======

        List :
            the plot interval as below:
                [parameter, lower_bound, upper_bound]

        Examples
        ========

        >>> from sympy import Curve, sin
        >>> from sympy.abc import x, 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]

        See Also
        ========

        limits : Returns limits of the parameter interval

        TrC   rN   N)r   r    listr   )r!   r    r>   s      r   plot_intervalzCurve.plot_interval/  s:    B It~D999sT$+abb/****r   r   Nc                    |rt          |d           }nt          dd          } | j        |j         }t          |j                  }|                    d           t          dd|          }|t          |          z  }|                     |dddf         	                                d         | j
                  }| } |j        |j         S )a  This function is used to rotate a curve along given point ``pt`` at given angle(in radian).

        Parameters
        ==========

        angle :
            the angle at which the curve will be rotated(in radian) in counterclockwise direction.
            default value of angle is 0.

        pt : Point
            the point along which the curve will be rotated.
            If no point given, the curve will be rotated around origin.

        Returns
        =======

        Curve :
            returns a curve rotated at given angle along given point.

        Examples
        ========

        >>> from sympy import Curve, pi
        >>> from sympy.abc import x
        >>> Curve((x, x), (x, 0, 1)).rotate(pi/2)
        Curve((-x, x), (x, 0, 1))

        r   dimr   rN   r   N)r	   	translater:   r`   r,   appendr   r   r<   tolistr   )r!   angleptrvr"   s        r   rotatezCurve.rotateS  s    :  	""""BBqBT^RW%	1aOO	YuYYqBQBx((+T[99Sr|RW%%r   rN   c                     |rBt          |d          }  | j        | j                             ||          j        |j         S | j        \  }}|                     ||z  ||z  f| j                  S )a^  Override GeometryEntity.scale since Curve is not made up of Points.

        Returns
        =======

        Curve :
            returns scaled curve.

        Examples
        ========

        >>> from sympy import Curve
        >>> from sympy.abc import x
        >>> Curve((x, x), (x, 0, 1)).scale(2)
        Curve((2*x, x), (x, 0, 1))

        r   rc   )r	   re   r:   scaler,   r<   r   )r!   xyri   fxfys         r   rm   zCurve.scale}  s{    $  	Orq!!!BD>4>RC:.44Q::DbgNNByy"Q$1t{333r   c                 \    | j         \  }}|                     ||z   ||z   f| j                  S )aL  Translate the Curve by (x, y).

        Returns
        =======

        Curve :
            returns a translated curve.

        Examples
        ========

        >>> from sympy import Curve
        >>> 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!   rn   ro   rp   rq   s        r   re   zCurve.translate  s2    $ Byy"q&"q&)4;777r   )r.   )r>   )r   N)rN   rN   N)r   r   )__name__
__module____qualname____doc__r   r#   r-   rA   rL   propertyrK   rT   r,   r   r    r^   ra   rk   rm   re   r&   r   r   r   r      ss       3 3jM M M, , ,F F F' ' ' '5A 5A 5A 5An   X6 ! ! X!,   X4   X4   X4 1 1 X1"+ "+ "+ "+H(& (& (& (&T4 4 4 408 8 8 8 8 8r   r   N)rv   (sympy.functions.elementary.miscellaneousr   
sympy.corer   sympy.core.containersr   sympy.core.symbolr   sympy.geometry.entityr   r   sympy.geometry.pointr	   sympy.integralsr
   sympy.matricesr   r   sympy.utilities.iterablesr   mpmath.libmp.libmpfr   r   r&   r   r   <module>r      s    : 9 9 9 9 9       ' ' ' ' ' ' % % % % % % = = = = = = = = & & & & & & % % % % % % , , , , , , , , 1 1 1 1 1 1 + + + + + +R8 R8 R8 R8 R8K R8 R8 R8 R8 R8r   