o
    9ôjº'  ã                   @   s˜   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„ 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                   @   s¬   e Zd ZdZdd„ Zdd„ Zdd„ Zd%d	d
„Zd&dd„Ze	dd„ ƒZ
e	dd„ ƒZe	dd„ ƒZe	dd„ ƒZe	dd„ ƒZe	dd„ ƒZd&dd„Zd'dd„Zd(d!d"„Zd)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                 C   s^   t |ƒr
t|ƒdkrtdt|ƒ ƒ‚t |ƒrt|ƒdkr$tdt|ƒ ƒ‚t | 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Úlimits© r   úe/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/sympy/geometry/curve.pyr   L   s   ÿÿzCurve.__new__c                 C   s   |   | j|¡S ©N)ÚsubsÚ	parameter)ÚselfÚfr   r   r   Ú__call__V   s   zCurve.__call__c                    s(   ˆ| j krt‡ ‡fdd„| jD ƒŽ S d S )Nc                    s   g | ]}|  ˆˆ ¡‘qS r   ©r   ©Ú.0r   ©ÚnewÚoldr   r   Ú
<listcomp>[   ó    z$Curve._eval_subs.<locals>.<listcomp>)r   r   Ú	functions)r   r%   r$   r   r#   r   Ú
_eval_subsY   s   
ÿzCurve._eval_subsé   c                    s^   | j \}\}}}t|ƒ‰ t‡ ‡fdd„|D ƒƒ}‡ ‡fdd„||fD ƒ\}}|  ||||f¡S )Nc                    ó    g | ]}|j dd ˆ iˆ¤Ž‘qS ©Únr   ©Úevalf©r"   Úi©ÚdpsÚoptionsr   r   r&   `   ó     z%Curve._eval_evalf.<locals>.<listcomp>c                    r+   r,   r.   r0   r2   r   r   r&   a   r5   )Úargsr   ÚtupleÚfunc)r   Úprecr4   r   ÚtÚaÚbr   r2   r   Ú_eval_evalf]   s
   zCurve._eval_evalfr:   c                    sr   |du r	t | jŽ S t|| jdd�‰| j‰ ˆjˆ jkr,ˆjdd„ | jD ƒv r,tdˆj ƒ‚t ‡ ‡fd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                 s   s   � | ]}|j V  qd S r   )Únamer!   r   r   r   Ú	<genexpr>–   s   € z(Curve.arbitrary_point.<locals>.<genexpr>zFSymbol %s already appears in object and cannot be used as a parameter.c                    s   g | ]}|  ˆ ˆ¡‘qS r   r    )r"   Úw©r:   Útnewr   r   r&   ™   r'   z)Curve.arbitrary_point.<locals>.<listcomp>)r   r(   r   r   r@   Úfree_symbolsr   )r   r   r   rC   r   Úarbitrary_pointd   s   ,
ÿzCurve.arbitrary_pointc                 C   s<   t ƒ }| j| jdd…  D ]}||jO }q| | 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   rE   Ú
differencer   )r   Úfreer;   r   r   r   rE   ›   s
   zCurve.free_symbolsc                 C   s   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   r6   ©r   r   r   r   Úambient_dimension·   s   zCurve.ambient_dimensionc                 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   ©r6   rK   r   r   r   r(   Î   ó   
zCurve.functionsc                 C   rM   )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

        rG   rN   rK   r   r   r   r   é   rO   zCurve.limitsc                 C   s   | 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

        rG   r   rN   rK   r   r   r   r     s   zCurve.parameterc                    s(   t t‡ fdd„ˆ jD ƒƒƒ}t|ˆ jƒS )zÃThe curve length.

        Examples
        ========

        >>> from sympy import Curve
        >>> 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 )r   r   N)r   r   )r"   r8   rK   r   r   rA   ,  s   €" zCurve.length.<locals>.<genexpr>)r   Úsumr(   r	   r   )r   Ú	integrandr   rK   r   Úlength  s   zCurve.lengthc                 C   s(   t || jdd�}|gt| jdd… ƒ 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

        Tr>   rG   N)r   r   Úlistr   )r   r   r:   r   r   r   Úplot_interval/  s   !zCurve.plot_intervalr   Nc                 C   sŠ   |r
t |dd� }nt ddƒ}| j|jŽ }t|jƒ}| d¡ tdd|ƒ}|t|ƒ9 }|  |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   rG   r   N)r   Ú	translater6   rS   r(   Úappendr
   r   r8   Útolistr   )r   ÚangleÚptÚrvr   r   r   r   ÚrotateS  s   


"zCurve.rotaterG   c                 C   sR   |rt |dd�}| j| jŽ  ||¡j|jŽ S | j\}}|  || || 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   rU   )r   rW   r6   Úscaler(   r8   r   )r   ÚxÚyr[   ÚfxÚfyr   r   r   r^   }  s
   
zCurve.scalec                 C   s$   | j \}}|  || || 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(   r8   r   )r   r_   r`   ra   rb   r   r   r   rW   •  s   
zCurve.translate)r*   )r:   )r   N)rG   rG   N)r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r)   r=   rF   ÚpropertyrE   rL   r(   r   r   rR   rT   r]   r^   rW   r   r   r   r   r      s.    5


7







$
*r   N)rf   Ú(sympy.functions.elementary.miscellaneousr   Ú
sympy.corer   Úsympy.core.containersr   Úsympy.core.symbolr   Zsympy.geometry.entityr   r   Úsympy.geometry.pointr   Úsympy.integralsr	   Úsympy.matricesr
   r   Úsympy.utilities.iterablesr   Úmpmath.libmp.libmpfr   r   r   r   r   r   Ú<module>   s    