a
    =b                     @   s:   d dgZ ddlZddlmZ edddd  Zd	d ZdS )
polygon_clippolygon_area    N   )require
matplotlibz>=3.0.3c                 C   s   ddl m}m} |jt| |fjdd}|||g||gg}	||		 d }
t
|
d |
d krt|
dd }
|
dddf |
dddf fS )	a  Clip a polygon to the given bounding box.

    Parameters
    ----------
    rp, cp : (N,) ndarray of double
        Row and column coordinates of the polygon.
    (r0, c0), (r1, c1) : double
        Top-left and bottom-right coordinates of the bounding box.

    Returns
    -------
    r_clipped, c_clipped : (M,) ndarray of double
        Coordinates of clipped polygon.

    Notes
    -----
    This makes use of Sutherland-Hodgman clipping as implemented in
    AGG 2.4 and exposed in Matplotlib.

    r   )path
transformsT)closedNr   )r   r   r   PathnpZvstackTZBboxZclip_to_bboxZto_polygonsall)ZrpZcpZr0Zc0Zr1Zc1r   r   ZpolyZ	clip_rectZpoly_clipped r   8lib/python3.9/site-packages/skimage/_shared/_geometry.pyr      s    c              
   C   sT   t | } t |}dt t |dd | dd  |dd | dd    S )zCompute the area of a polygon.

    Parameters
    ----------
    pr, pc : (N,) array of float
        Polygon row and column coordinates.

    Returns
    -------
    a : float
        Area of the polygon.
    g      ?Nr
   r   )r   Zasarrayabssum)ZprZpcr   r   r   r   +   s    

)__all__Znumpyr   Zversion_requirementsr   r   r   r   r   r   r   <module>   s
   
"