o
    §ƒð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 ],}t |ttfƒr6t|ƒdkr"tdƒ‚||d f7 }|d |d f||d < q||f7 }qt |ttfƒsF|f}tƒ j| t|Ž g|¢R Ž }||_||_|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   úŸ/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/sympy/vector/parametricregion.pyr   6   s"   
zParametricRegion.__new__c                 C   s
   | j d S )Nr   )Úargs©Úselfr   r   r&   r   O   ó   
zParametricRegion.definitionc                 C   ó   | j S ©N)r   r(   r   r   r&   r!   S   ó   zParametricRegion.limitsc                 C   r+   r,   )r   r(   r   r   r&   r    W   r-   zParametricRegion.parametersc                 C   s
   t | jƒS r,   )r   r!   r(   r   r   r&   Ú
dimensions[   r*   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ƒ‚)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.)r   )Úregr   r   r&   Úparametric_region_list`   s   #r6   c                 C   s   t | jƒgS r,   )r   r'   )r#   r   r   r&   Ú_†   s   r7   c                 C   s    |   | j¡j}| j}t||ƒgS r,   )Úarbitrary_pointÚ	parameterr'   r!   r   )r#   r   r   r   r   r&   r7   ‹   s   Útc                 C   s2   |   |¡j}t|dd�}|ddt f}t||ƒgS )NT©Úrealr   r   )r8   r'   r   r   r   )r#   r9   r   r:   r   r   r   r&   r7   ’   s   c           	      C   sª   t |dd�}|  |¡j}tddƒD ]7}t|| | jd j|  |ƒ}t|| | jd j|  |ƒ}t|ƒdkrHt|ƒdkrH||d |d f} nq|  |¡j}t||ƒgS )NTr;   r   r   r   )r   r8   r'   Úranger	   Úpointsr   r   )	r#   r9   r:   r   ÚiÚlower_boundÚupper_boundr   Údefinition_tupler   r   r&   r7   š   s   €c                    s   ‡ fdd„| j D ƒ}|S )Nc                    s   g | ]	}t |ˆ ƒd  ‘qS )r   )r6   )Ú.0Úside©r9   r   r&   Ú
<listcomp>­   s    ú_.<locals>.<listcomp>)Úsides)r#   r9   Úlr   rE   r&   r7   «   s   ©r:   Úsc                    sv   |   |¡}g }tt| jƒd ƒD ]}t|| dd�‰ ‡ fdd„|D ƒ}| ˆ ddt f¡ qt|Ž }t|g|¢R Ž gS )Nr   Tr;   c              	      s$   g | ]}t | ˆ tˆ d  ƒ¡ƒ‘qS )r   )r   Úsubsr   )rC   ÚelemrE   r   r&   rF   ¹   s   $ rG   r   r   )	Úrational_parametrizationr=   r   Ú	variablesr   Úappendr   r   r   )r#   r    r   r   r?   r   rE   r&   r7   ±   s   
N)r:   )rJ   )Ú	functoolsr   Úsympy.core.numbersr   Ú(sympy.functions.elementary.trigonometricr   Úsympy.simplifyr   Ú
sympy.corer   r   Úsympy.core.symbolr   Úsympy.solversr	   Úsympy.geometryr
   r   r   r   r   Úsympy.vectorr   r   r6   Úregisterr7   r   r   r   r&   Ú<module>   s0    T
%

