
    |h?                     D    d dgZ ddlZddlmZ  edd      d        Zd	 Zy)
polygon_clippolygon_area    N   )require
matplotlibz>=3.3c                    ddl m}m} |j                  t	        j
                  | |f      j                  d      }|j                  ||g||gg      }	|j                  |	      j                         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              X/var/www/html/test/engine/venv/lib/python3.12/site-packages/skimage/_shared/_geometry.pyr   r      s    , ,99RYYBx(**498D"bB8 45I$$Y/;;=a@L1|AqD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   '   sb     
BB	BB3B"QR& 0RVb"g5EFGHHHr   )__all__numpyr   version_requirementsr   r   r    r   r   <module>r)      s6   >
*  ) 	w2  2<Ir   