
    Ed,                     (   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                    e          d             Ze                    e          d             Ze                    e          dd            Ze                    e          dd            Ze                    e          dd            Ze                    e          dd            ZdS )    )singledispatch)pi)tan)trigsimp)BasicTuple)_symbol)solve)PointSegmentCurveEllipsePolygon)ImplicitRegionc                   z     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                    d}i }t          |t                    s	t          | }|D ]l}t          |t          t          f          rHt          |          dk    rt	          d          ||d         fz  }|d         |d         f||d         <   f||fz  }mt          |t          t          f          s|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__s          =lib/python3.11/site-packages/sympy/vector/parametricregion.pyr   zParametricRegion.__new__6   s    
&%(( 	$F^F 	' 	'E%%00 'u::? h$%fggguQxk)
$)!HeAh#7uQx  uh&

*uen55 	'$Jeggoc5*#5????$
    c                     | j         d         S )Nr   )argsselfs    r(   r!   zParametricRegion.definitionO   s    y|r)   c                     | j         S N)r   r,   s    r(   r$   zParametricRegion.limitsS   s
    |r)   c                     | j         S r/   )r   r,   s    r(   r#   zParametricRegion.parametersW   s    r)   c                 *    t          | j                  S r/   )r   r$   r,   s    r(   
dimensionszParametricRegion.dimensions[   s    4;r)   )__name__
__module____qualname____doc__r   propertyr!   r$   r#   r2   __classcell__)r'   s   @r(   r   r      s        ( (R    2   X   X     X      X         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
WWr)   c                 ,    t          | j                  gS r/   )r   r+   )r&   s    r(   _r=      s    SX&&''r)   c                 p    |                      | j                  j        }| j        }t	          ||          gS r/   )arbitrary_point	parameterr+   r$   r   )r&   r!   r"   s      r(   r=   r=      s4    $$S]338JZFZ0011r)   tc                     |                      |          j        }t          |d          }|ddt          z  f}t	          ||          gS )NTrealr   r   )r?   r+   r	   r   r   )r&   r@   r!   rA   r"   s        r(   r=   r=      sL    $$Y//4J	%%%AAbD\FZ0011r)   c                    t          |d          }|                     |          j        }t          dd          D ]}t	          ||         | j        d         j        |         z
  |          }t	          ||         | j        d         j        |         z
  |          }t          |          dk    r&t          |          dk    r||d         |d         f} n|                     |          j        }t          ||          gS )NTrC   r   r   r   )r	   r?   r+   ranger
   pointsr   r   )	r&   r@   rA   r!   ilower_boundupper_boundr"   definition_tuples	            r(   r=   r=      s    	%%%A$$Q'',J1a[[  JqMCJqM,>q,AA1EEJqMCJqM,>q,AA1EE{q  	S%5%5%: 	AA6FE**955:-v6677r)   c                 .    fd| j         D             }|S )Nc                 <    g | ]}t          |          d          S )r   )r;   ).0sider@   s     r(   
<listcomp>z_.<locals>.<listcomp>   s)    JJJ	i	0	0	3JJJr)   )sides)r&   r@   ls    ` r(   r=   r=      s#    JJJJ	JJJAHr)   rA   sc                 8   |                      |          }g }t          t          | j                  dz
            D ]G}t	          ||         d          fd|D             }|                    ddt          z  f           Ht          | }t          |g|R  gS )Nr   TrC   c                 v    g | ]5}t          |                    t          d z                                6S )r   )r   subsr   )rN   elemr@   s     r(   rP   z_.<locals>.<listcomp>   s;    ^^^4htyyC	!4D4DEEFF^^^r)   r   r   )	rational_parametrizationrF   r   	variablesr	   appendr   r   r   )r&   r#   r!   r"   rH   r@   s        @r(   r=   r=      s    --j99JF3s}%%)** - -JqM555	^^^^S]^^^
y!QrT*,,,,
#JZ1&11122r)   N)rA   )rS   )	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>rf      s1   $ $ $ $ $ $ ! ! ! ! ! ! 8 8 8 8 8 8 # # # # # # # # # # # # # # % % % % % %       B B B B B B B B B B B B B B ' ' ' ' ' 'Q  Q  Q  Q  Q u Q  Q  Q h "X "X "XJ   ''( ( ('(   ''2 2 ('2   ))2 2 2 *)2   ))8 8 8 *)8    ))   *)
   003 3 3 103 3 3r)   