U
    ?h?                     @   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.3c                 C   sr   ddl m}m} |jt| |fjdd}|||g||gg}	||		 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)rpcpZr0Zc0r1c1r   r   ZpolyZ	clip_rectZpoly_clipped r   K/var/www/html/venv/lib/python3.8/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   Zasarrayabssum)prZpcr   r   r   r   '   s    

)__all__numpyr   Zversion_requirementsr   r   r   r   r   r   r   <module>   s
   
