U
    ZÊ¹j,  ã                   @   s  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mZmZmZ d d	lmZ G d
d„ de	ƒZedd„ ƒZe e¡dd„ ƒZe e¡dd„ ƒZe e¡ddd„ƒZe e¡ddd„ƒZe e¡ddd„ƒZe e¡ddd„ƒZdS )é    )Úsingledispatch)Úpi)Útan)Útrigsimp)ÚBasicÚTuple)Ú_symbol)Úsolve)ÚPointÚSegmentÚCurveÚEllipseÚPolygon)ÚImplicitRegionc                       sP   e Zd ZdZ‡ fdd„Zedd„ ƒZedd„ ƒZedd	„ ƒZed
d„ ƒZ	‡  Z
S )ÚParametricRegiona  
    Represents a parametric region in space.

    Examples
    ========

    >>> from sympy import cos, sin, pi
    >>> from sympy.abc import r, theta, t, a, b, x, y
    >>> from sympy.vector import ParametricRegion

    >>> ParametricRegion((t, t**2), (t, -1, 2))
    ParametricRegion((t, t**2), (t, -1, 2))
    >>> ParametricRegion((x, y), (x, 3, 4), (y, 5, 6))
    ParametricRegion((x, y), (x, 3, 4), (y, 5, 6))
    >>> ParametricRegion((r*cos(theta), r*sin(theta)), (r, -2, 2), (theta, 0, pi))
    ParametricRegion((r*cos(theta), r*sin(theta)), (r, -2, 2), (theta, 0, pi))
    >>> ParametricRegion((a*cos(t), b*sin(t)), t)
    ParametricRegion((a*cos(t), b*sin(t)), t)

    >>> circle = ParametricRegion((r*cos(theta), r*sin(theta)), r, (theta, 0, pi))
    >>> circle.parameters
    (r, theta)
    >>> circle.definition
    (r*cos(theta), r*sin(theta))
    >>> circle.limits
    {theta: (0, pi)}

    Dimension of a parametric region determines whether a region is a curve, surface
    or volume region. It does not represent its dimensions in space.

    >>> circle.dimensions
    1

    Parameters
    ==========

    definition : tuple to define base scalars in terms of parameters.

    bounds : Parameter or a tuple of length 3 to define parameter and corresponding lower and upper bound.

    c                    s´   d}i }t |tƒst|Ž }|D ]X}t |ttfƒrlt|ƒdkrDtdƒ‚||d f7 }|d |d f||d < q||f7 }qt |ttfƒsŒ|f}tƒ j| t|Ž f|žŽ }||_||_|S )N© é   z?Tuple should be in the form (parameter, lowerbound, upperbound)r   é   é   )	Ú
isinstancer   ÚtupleÚlenÚ
ValueErrorÚsuperÚ__new__Ú_parametersÚ_limits)ÚclsÚ
definitionÚboundsÚ
parametersÚlimitsÚboundÚobj©Ú	__class__r   ú\/var/www/html/bwave/python/venv/lib/python3.8/site-packages/sympy/vector/parametricregion.pyr   6   s"    
zParametricRegion.__new__c                 C   s
   | j d S )Nr   )Úargs©Úselfr   r   r&   r   O   s    zParametricRegion.definitionc                 C   s   | j S ©N)r   r(   r   r   r&   r!   S   s    zParametricRegion.limitsc                 C   s   | j S r*   )r   r(   r   r   r&   r    W   s    zParametricRegion.parametersc                 C   s
   t | jƒS r*   )r   r!   r(   r   r   r&   Ú
dimensions[   s    zParametricRegion.dimensions)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r!   r    r+   Ú__classcell__r   r   r$   r&   r      s   )


r   c                 C   s   t dƒ‚dS )aN  
    Returns a list of ParametricRegion objects representing the geometric region.

    Examples
    ========

    >>> from sympy.abc import t
    >>> from sympy.vector import parametric_region_list
    >>> from sympy.geometry import Point, Curve, Ellipse, Segment, Polygon

    >>> p = Point(2, 5)
    >>> parametric_region_list(p)
    [ParametricRegion((2, 5))]

    >>> c = Curve((t**3, 4*t), (t, -3, 4))
    >>> parametric_region_list(c)
    [ParametricRegion((t**3, 4*t), (t, -3, 4))]

    >>> e = Ellipse(Point(1, 3), 2, 3)
    >>> parametric_region_list(e)
    [ParametricRegion((2*cos(t) + 1, 3*sin(t) + 3), (t, 0, 2*pi))]

    >>> s = Segment(Point(1, 3), Point(2, 6))
    >>> parametric_region_list(s)
    [ParametricRegion((t + 1, 3*t + 3), (t, 0, 1))]

    >>> p1, p2, p3, p4 = [(0, 1), (2, -3), (5, 3), (-2, 3)]
    >>> poly = Polygon(p1, p2, p3, p4)
    >>> parametric_region_list(poly)
    [ParametricRegion((2*t, 1 - 4*t), (t, 0, 1)), ParametricRegion((3*t + 2, 6*t - 3), (t, 0, 1)),     ParametricRegion((5 - 7*t, 3), (t, 0, 1)), ParametricRegion((2*t - 2, 3 - 2*t),  (t, 0, 1))]

    z?SymPy cannot determine parametric representation of the region.N)r   )Úregr   r   r&   Úparametric_region_list`   s    #r3   c                 C   s   t | jƒgS r*   )r   r'   )r#   r   r   r&   Ú_†   s    r4   c                 C   s    |   | j¡j}| j}t||ƒgS r*   )Úarbitrary_pointÚ	parameterr'   r!   r   )r#   r   r   r   r   r&   r4   ‹   s    Útc                 C   s2   |   |¡j}t|dd�}|ddt f}t||ƒgS )NT©Úrealr   r   )r5   r'   r   r   r   )r#   r6   r   r7   r   r   r   r&   r4   ’   s    c           	      C   sª   t |dd�}|  |¡j}tddƒD ]n}t|| | jd j|  |ƒ}t|| | jd j|  |ƒ}t|ƒdkr"t|ƒdkr"||d |d f} q’q"|  |¡j}t||ƒgS )NTr8   r   r   r   )r   r5   r'   Úranger	   Zpointsr   r   )	r#   r6   r7   r   ÚiÚlower_boundÚupper_boundr   Zdefinition_tupler   r   r&   r4   š   s    c                    s   ‡ fdd„| j D ƒ}|S )Nc                    s   g | ]}t |ˆ ƒd  ‘qS )r   )r3   )Ú.0Zside©r6   r   r&   Ú
<listcomp>­   s     ú_.<locals>.<listcomp>)Zsides)r#   r6   Úlr   r?   r&   r4   «   s    ©r7   Úsc                    st   |   |¡}g }tt| jƒd ƒD ]:}t|| dd�‰ ‡ fdd„|D ƒ}| ˆ ddt f¡ q t|Ž }t|f|žŽ gS )Nr   Tr8   c              	      s$   g | ]}t | ˆ tˆ d  ƒ¡ƒ‘qS )r   )r   Úsubsr   )r>   Úelemr?   r   r&   r@   ¹   s     rA   r   r   )	Zrational_parametrizationr:   r   Ú	variablesr   Úappendr   r   r   )r#   r    r   r   r;   r   r?   r&   r4   ±   s    
N)r7   )r7   )r7   )rC   )Ú	functoolsr   Zsympy.core.numbersr   Z(sympy.functions.elementary.trigonometricr   Zsympy.simplifyr   Z
sympy.corer   r   Zsympy.core.symbolr   Zsympy.solversr	   Zsympy.geometryr
   r   r   r   r   Zsympy.vectorr   r   r3   Úregisterr4   r   r   r   r&   Ú<module>   s.   T
%

