
    ^jp                        d dl mZ d dlmZ d dlmZ d dlmZ  G d de      Ze G d d             Z	e G d	 d
             Z
e G d d             Zy)    )annotations)	dataclass)Enum)sqrtc                  J    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZedd       Zy)Positionz<
    Enum representing the position of an anchor point.
    CENTERCENTER_LEFTCENTER_RIGHT
TOP_CENTERTOP_LEFT	TOP_RIGHTBOTTOM_LEFTBOTTOM_CENTERBOTTOM_RIGHTCENTER_OF_MASSc                .    t        t        d |             S )Nc                    | j                   S N)value)cs    d/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/supervision/geometry/core.py<lambda>zPosition.list.<locals>.<lambda>   s
    !''     )listmap)clss    r   r   zPosition.list   s    C)3/00r   N)returnz	list[str])__name__
__module____qualname____doc__r	   r
   r   r   r   r   r   r   r   r   classmethodr    r   r   r   r      sM     FK!LJHIK#M!L%N1 1r   r   c                  6    e Zd ZU dZded<   ded<   ddZd	dZy)
Pointa  
    Represents a point in 2D space.

    Attributes:
        x: The x-coordinate of the point.
        y: The y-coordinate of the point.

    Example:
        ```pycon
        >>> from supervision.geometry.core import Point
        >>> point = Point(x=10.0, y=20.0)
        >>> point.as_xy_int_tuple()
        (10, 20)
        >>> point.as_xy_float_tuple()
        (10.0, 20.0)

        ```
    floatxyc                V    t        | j                        t        | j                        fS )zw
        Returns the point as a tuple of integers.

        Returns:
            The point as (x, y) integers.
        )intr(   r)   selfs    r   as_xy_int_tuplezPoint.as_xy_int_tuple5   s     466{CK''r   c                2    | j                   | j                  fS )zs
        Returns the point as a tuple of floats.

        Returns:
            The point as (x, y) floats.
        r(   r)   r,   s    r   as_xy_float_tuplezPoint.as_xy_float_tuple>   s     vvtvv~r   N)r   ztuple[int, int])r   ztuple[float, float])r   r    r!   r"   __annotations__r.   r1   r$   r   r   r&   r&      s    & HH(r   r&   c                  R    e Zd ZU dZded<   ded<   ed	d       Zed
d       ZddZy)Vectora  
    Represents a vector in 2D space, defined by a start and an end point.

    Attributes:
        start: The starting point of the vector.
        end: The end point of the vector.

    Example:
        ```pycon
        >>> from supervision.geometry.core import Point, Vector
        >>> start_point = Point(x=0.0, y=0.0)
        >>> end_point = Point(x=3.0, y=4.0)
        >>> vector = Vector(start=start_point, end=end_point)
        >>> vector.magnitude
        5.0
        >>> vector.center
        Point(x=1.5, y=2.0)

        ```
    r&   startendc                    | j                   j                  | j                  j                  z
  }| j                   j                  | j                  j                  z
  }t	        |dz  |dz  z         S )z|
        Calculate the magnitude (length) of the vector.

        Returns:
            The magnitude of the vector.
           )r6   r(   r5   r)   r   )r-   dxdys      r   	magnitudezVector.magnitudeb   sO     XXZZ$**,,&XXZZ$**,,&BEBEM""r   c                    t        | j                  j                  | j                  j                  z   dz  | j                  j                  | j                  j                  z   dz        S )zy
        Calculate the center point of the vector.

        Returns:
            The center point of the vector.
        r8   r0   )r&   r5   r(   r6   r)   r,   s    r   centerzVector.centern   sK     zz||dhhjj(A-zz||dhhjj(A-
 	
r   c                X   | j                   j                  | j                  j                  z
  }| j                   j                  | j                  j                  z
  }|j                  | j                  j                  z
  }|j                  | j                  j                  z
  }||z  ||z  z
  S )ah  
        Calculate the 2D cross product (also known as the vector product or outer
        product) of the vector and a point, treated as vectors in 2D space.

        Args:
            point: The point to be evaluated, treated as the endpoint of a
                vector originating from the 'start' of the main vector.

        Returns:
            The scalar value of the cross product. It is positive if 'point'
                lies to the left of the vector (when moving from 'start' to 'end'),
                negative if it lies to the right, and 0 if it is collinear with the
                vector.
        )r6   r(   r5   r)   )r-   point	dx_vector	dy_vectordx_pointdy_points         r   cross_productzVector.cross_product{   sy     HHJJ-	HHJJ-	77TZZ\\)77TZZ\\)H$X)=>>r   N)r   r'   r   r&   )r?   r&   r   r'   )	r   r    r!   r"   r2   propertyr;   r=   rD   r$   r   r   r4   r4   H   s>    * L	J	# 	# 

 

?r   r4   c                      e Zd ZU dZded<   ded<   ded<   ded<   edd       Zedd       Zedd	       Z	dd
Z
ddZy)Rectav  
    Represents a rectangle in 2D space.

    Attributes:
        x: The x-coordinate of the top-left corner of the rectangle.
        y: The y-coordinate of the top-left corner of the rectangle.
        width: The width of the rectangle.
        height: The height of the rectangle.

    Example:
        ```pycon
        >>> from supervision.geometry.core import Rect
        >>> rect = Rect(x=10.0, y=20.0, width=30.0, height=40.0)
        >>> rect.top_left
        Point(x=10.0, y=20.0)
        >>> rect.bottom_right
        Point(x=40.0, y=60.0)
        >>> rect.as_xyxy_int_tuple()
        (10, 20, 40, 60)

        ```
    r'   r(   r)   widthheightc                4    |\  }}}} | ||||z
  ||z
        S )Nr(   r)   rI   rJ   r$   )r   xyxyx1y1x2y2s         r   	from_xyxyzRect.from_xyxy   s(    BBR2R"WR"W==r   c                D    t        | j                  | j                        S Nr0   )r&   r(   r)   r,   s    r   top_leftzRect.top_left   s    tvv((r   c                x    t        | j                  | j                  z   | j                  | j                  z         S rT   )r&   r(   rI   r)   rJ   r,   s    r   bottom_rightzRect.bottom_right   s)    tvv

*dfft{{.BCCr   c                    t        | j                  |z
  | j                  |z
  | j                  d|z  z   | j                  d|z  z         S )Nr8   rL   )rH   r(   r)   rI   rJ   )r-   paddings     r   padzRect.pad   sG    ffwffw**q7{*;;W,	
 	
r   c                    t        | j                        t        | j                        t        | j                  | j                  z         t        | j                  | j                  z         fS r   )r+   r(   r)   rI   rJ   r,   s    r   as_xyxy_int_tuplezRect.as_xyxy_int_tuple   sL    KK#$$%	
 	
r   N)rM   z!tuple[float, float, float, float]r   rH   rE   )rY   r+   r   rH   )r   ztuple[int, int, int, int])r   r    r!   r"   r2   r#   rR   rF   rU   rW   rZ   r\   r$   r   r   rH   rH      sc    . HHLM> > ) ) D D

r   rH   N)
__future__r   dataclassesr   enumr   mathr   r   r&   r4   rH   r$   r   r   <module>ra      sm    " !  1t 1* ' ' 'T E? E? E?P 8
 8
 8
r   