o
    oh,                     @   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   q/var/www/html/construction_image-detection-poc/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
%

