o
    g÷§iþ  ã                   @   s>   d Z ddlZddlmZ ddlZddlmZ G dd„ dƒZdS )z&
This class represents a line segment
é    N)ÚDecimal)ÚMatrixc                   @   sz   e Zd ZdZdedededefdd„Zdejeef fd	d
„Zdejeef fdd„Z	defdd„Z
dedd fdd„ZdS )ÚLineSegmentz.
    This class represents a line segment
    Úx0Úy0Úx1Úy1c                 C   s   || _ || _|| _|| _d S )N)r   r   r   r   )Úselfr   r   r   r   © r
   úY/home/ubuntu/.local/lib/python3.10/site-packages/borb/pdf/canvas/geometry/line_segment.pyÚ__init__   s   
zLineSegment.__init__Úreturnc                 C   ó   | j | jfS )z‚
        This function returns the end of this LineSegment
        :return:    the end (second point) of this LineSegment
        )r   r   ©r	   r
   r
   r   Úget_end%   ó   zLineSegment.get_endc                 C   r   )z…
        This function returns the start of this LineSegment
        :return:    the start (first point) of this LineSegment
        )r   r   r   r
   r
   r   Ú	get_start,   r   zLineSegment.get_startc                 C   s*   t t | j| j d | j| j d  ¡ƒS )zy
        This function returns the length of this LineSegment
        :return:    the length of this LineSegment
        é   )r   ÚmathÚsqrtr   r   r   r   r   r
   r
   r   Úlength3   s   *zLineSegment.lengthÚmatrixc                 C   sJ   |  | j| jtdƒ¡}|  | j| jtdƒ¡}t|d |d |d |d ƒS )zý
        This function transforms the start and end of this LineSegment by a given Matrix,
        it returns the transformed LineSegment
        :param matrix:  the matrix to transform by
        :return:        a new (transformed) LineSegment
        é   r   )Úcrossr   r   r   r   r   r   )r	   r   Úp0Úp1r
   r
   r   Útransform_by:   s   zLineSegment.transform_byN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   ÚtypingÚTupler   r   r   r   r   r
   r
   r
   r   r      s    r   )r    r!   Údecimalr   r   Úborb.pdf.canvas.geometry.matrixr   r   r
   r
   r
   r   Ú<module>   s   