
    0-Ph?                     R    d dgZ ddlZddlmZ  edd          d             Zd	 ZdS )
polygon_clippolygon_area    N   )require
matplotlibz>=3.3c                 2   ddl m}m} |                    t	          j        | |f          j        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 : (K,) 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 : (L,) 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npvstackTBboxclip_to_bboxto_polygons)rpcpr0c0r1c1r	   r
   poly	clip_rectpoly_clippeds              Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/skimage/_shared/_geometry.pyr   r      s    , ,+++++++99RYBx((*4988D"bB8 455I$$Y//;;==a@L1|AAAqD111    c           
          t          j        |           } t          j        |          }dt          j        t          j        |dd         | dd         z  |dd         | dd         z  z
                      z  S )zCompute the area of a polygon.

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

    Returns
    -------
    a : float
        Area of the polygon.
    g      ?Nr   )r   asarrayabssum)prpcs     r   r   r   '   sl     
BB	BB3B3"QRR& 0RVb"g5EFGGHHHHr   )__all__numpyr   version_requirementsr   r   r    r   r   <module>r)      ss   >
*     ) ) ) ) ) ) 	w2 2  2<I I I I Ir   