
    wg,                        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e	      Zed        Zej3                  e      d        Zej3                  e      d        Zej3                  e      dd       Zej3                  e      dd       Zej3                  e      dd       Zej3                  e      dd       Zy)    )singledispatch)pi)tan)trigsimp)BasicTuple)_symbol)solve)PointSegmentCurveEllipsePolygon)ImplicitRegionc                   b     e Zd ZdZ fdZed        Zed        Zed        Zed        Z	 x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                 h   d}i }t        |t              st        | }|D ]Q  }t        |t        t        f      r3t        |      dk7  rt	        d      ||d   fz  }|d   |d   f||d   <   L||fz  }S t        |t        t        f      s|f}t        |   | t        | g| }||_        ||_        |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__s          b/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/vector/parametricregion.pyr   zParametricRegion.__new__6   s    
&%(F^F 	'E%%0u:?$%fgguQxk)
$)!HeAh#7uQx uh&
	' *uen5$Jgoc5*#5??$
    c                      | j                   d   S Nr   )argsselfs    r(   r!   zParametricRegion.definitionO   s    yy|r)   c                     | j                   S N)r   r-   s    r(   r$   zParametricRegion.limitsS   s    ||r)   c                     | j                   S r0   )r   r-   s    r(   r#   zParametricRegion.parametersW   s    r)   c                 ,    t        | j                        S r0   )r   r$   r-   s    r(   
dimensionszParametricRegion.dimensions[   s    4;;r)   )__name__
__module____qualname____doc__r   propertyr!   r$   r#   r3   __classcell__)r'   s   @r(   r   r      s^    (R2            r)   r   c                     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   )regs    r(   parametric_region_listr<   `   s    F V
WWr)   c                 .    t        | j                        gS r0   )r   r,   )r&   s    r(   _r>      s    SXX&''r)   c                 ~    | j                  | j                        j                  }| j                  }t	        ||      gS r0   )arbitrary_point	parameterr,   r$   r   )r&   r!   r"   s      r(   r>   r>      s5    $$S]]388JZZFZ011r)   c                     | j                  |      j                  }t        |d      }|ddt        z  f}t	        ||      gS )NTrealr   r   )r@   r,   r	   r   r   )r&   rA   r!   tr"   s        r(   r>   r>      sC    $$Y/44J	%AAbD\FZ011r)   c                    t        |d      }| j                  |      j                  }t        dd      D ]  }t	        ||   | j
                  d   j                  |   z
  |      }t	        ||   | j
                  d   j                  |   z
  |      }t        |      dk(  sjt        |      dk(  sy||d   |d   f} n | j                  |      j                  }t        |      gS )NTrC   r   r   r   )r	   r@   r,   ranger
   pointsr   r   )	r&   rA   rE   r!   ilower_boundupper_boundr"   definition_tuples	            r(   r>   r>      s    	%A$$Q',,J1a[ JqMCJJqM,>,>q,AA1EJqMCJJqM,>,>q,AA1E{q S%5%:AA6F **95::-v677r)   c                 \    | j                   D cg c]  }t        ||      d    }}|S c c}w r+   )sidesr<   )r&   rA   sidels       r(   r>   r>      s1    @C		J	i	0	3JAJH 	Ks   )c                 f   | j                  |      }g }t        t        | j                        dz
        D ]a  }t	        ||   d      }|D cg c])  }t        |j                  |t        |dz                    + }}|j                  |ddt        z  f       c t        | }t        |g| gS c c}w )Nr   TrC   r   r   )rational_parametrizationrG   r   	variablesr	   r   subsr   appendr   r   r   )r&   r#   r!   r"   rI   rA   elems          r(   r>   r>      s    --j9JF3s}}%)* -JqM5	S]^4htyyC	!4DEF^
^y!QrT*,	- 
#JZ1&122	 _s   .B.N)rE   ))rE   s)	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   r<   registerr>   r   r)   r(   <module>rb      s   $ ! 8 # # %  B B 'Q u Q h "X "XJ   '( ((   '2 (2   )2 *2   )8 *8    ) *
   03 13r)   