Ë
    £èh÷  ã                  óÀ   — d dl mZ d dlmZ d dlZd dlmZmZ g d¢Zdd„Z	dd„Z
	 	 	 	 	 	 	 	 	 	 dd„Zdd	„Z	 	 	 	 	 	 	 	 dd
„Zdd„Z	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zdd„Zy)é    )Úannotations)ÚAnyN)ÚVec2ÚUVec)Úbulge_to_arcÚbulge_3_pointsÚbulge_centerÚbulge_radiusÚarc_to_bulgeÚbulge_from_radius_and_chordÚbulge_from_arc_anglec                óF   — t        | «      t        j                  ||«      z   S )zÇReturns the point at a specified `angle` and `distance` from point `p`.

    Args:
        p: point as :class:`Vec2` compatible object
        angle: angle in radians
        distance: distance

    )r   Ú
from_angle)ÚpÚangleÚdistances      ú0lib/python3.12/site-packages/ezdxf/math/bulge.pyÚpolarr      s   € ô �‹7”T—_‘_ U¨HÓ5Ñ5Ð5ó    c                óD   — t        |«      t        | «      z
  j                  S )zÉReturns angle a line defined by two endpoints and x-axis in radians.

    Args:
        p1: start point as :class:`Vec2` compatible object
        p2: end point as :class:`Vec2` compatible object

    )r   r   )Úp1Úp2s     r   r   r   "   s   € ô �‹H”t˜B“xÑ×&Ñ&Ð&r   c                óú   — t        | ||«      }t        | ||«      }t        j                  dz  }t        j                  |||z
  z   |«      dz  }t        j                  |«      t        j
                  |«      z  }|||fS )a4  Returns bulge parameters from arc parameters.

    Args:
        center: circle center point as :class:`Vec2` compatible object
        start_angle: start angle in radians
        end_angle: end angle in radians
        radius: circle radius

    Returns:
        tuple: (start_point, end_point, bulge)

    é   ç      @)r   ÚmathÚpiÚfmodÚsinÚcos)	ÚcenterÚstart_angleÚ	end_angleÚradiusÚstart_pointÚ	end_pointÚpi2ÚaÚbulges	            r   r   r   -   ss   € ô ˜ ¨VÓ4€KÜ�f˜i¨Ó0€IÜ
�'‰'�A‰+€CÜ�	‰	�3˜) kÑ1Ñ2°SÓ9¸CÑ?€AÜ�H‰H�Q‹Kœ$Ÿ(™( 1›+Ñ%€EØ˜	 5Ð(Ð(r   c                ó²   — t         j                  t        || «      z
  t        ||«      z   dz  }t        j                  |«      t        j                  |«      z  S )a2  Returns bulge value defined by three points.

    Based on 3-Points to Bulge by `Lee Mac`_.

    Args:
        start_point: start point as :class:`Vec2` compatible object
        end_point: end point as :class:`Vec2` compatible object
        point: arbitrary point as :class:`Vec2` compatible object

    r   )r   r   r   r   r    )r%   r&   Úpointr(   s       r   r   r   D   sE   € ô 
�‰”5˜ Ó,Ñ	,¬u°U¸IÓ/FÑ	FÈ!ÑK€AÜ�8‰8�A‹;œŸ™ !›Ñ$Ð$r   c                ó>  — t        | ||«      }t        | |«      t        j                  dz  t        j                  |«      dz  z
  z   }t        | ||«      }|dk  r#|t        ||«      t        || «      t        |«      fS |t        || «      t        ||«      t        |«      fS )a4  Returns arc parameters from bulge parameters.

    The arcs defined by bulge values of :class:`~ezdxf.entities.LWPolyline`
    and 2D :class:`~ezdxf.entities.Polyline` entities start at the vertex which
    includes the bulge value and ends at the following vertex.

    .. important::

        The return values always describe a counter-clockwise oriented arc, so for
        clockwise arcs (negative bulge values) the start and end angles are swapped and
        the arc starts at the `end_point` and ends at the `start_point`.

    Based on Bulge to Arc by `Lee Mac`_.

    Args:
        start_point: start vertex as :class:`Vec2` compatible object
        end_point: end vertex as :class:`Vec2` compatible object
        bulge: bulge value

    Returns:
        Tuple: (center, start_angle, end_angle, radius)

    r   r   )Úsigned_bulge_radiusr   r   r   Úatanr   Úabs)r%   r&   r)   Úrr(   Úcs         r   r   r   S   s•   € ô4 	˜K¨°EÓ:€AÜˆk˜9Ó%¬¯©°1©´t·y±yÀÓ7GÈ!Ñ7KÑ)KÑL€AÜˆk˜1˜aÓ €AØˆq‚yØ”%˜˜9Ó%¤u¨Q°Ó'<¼cÀ!»fÐDÐDà”%˜˜;Ó'¬¨q°)Ó)<¼cÀ!»fÐDÐDr   c           	     óÒ   — t        | «      } t        | |«      t        j                  dz  t        j                  |«      dz  z
  z   }| t        j
                  |t        | ||«      «      z   S )a#  Returns center of arc described by the given bulge parameters.

    Based on  Bulge Center by `Lee Mac`_.

    Args:
        start_point: start point as :class:`Vec2` compatible object
        end_point: end point as :class:`Vec2` compatible object
        bulge: bulge value as float


    ç       @)r   r   r   r   r.   r   r-   )r%   r&   r)   r(   s       r   r	   r	   v   sa   € ô �{Ó#€KÜˆk˜9Ó%¬¯©°3©¼¿¹À5Ó9IÈCÑ9OÑ)OÑP€AØœŸ™Ø	Ô˜{¨I°uÓ=óñ ð r   c                óf   — t        | «      j                  t        |«      «      d||z  z   z  dz  |z  S )Nç      ð?r   )r   r   ©r%   r&   r)   s      r   r-   r-   ‰   sC   € ô 	ˆ[Ó×"Ñ"¤4¨	£?Ó3Ø�%˜%‘-Ñ ñ	"à
ñ	ð ñ	ðr   c                ó.   — t        t        | ||«      «      S )a  Returns radius of arc defined by the given bulge parameters.

    Based on Bulge Radius by `Lee Mac`_

    Args:
        start_point: start point as :class:`Vec2` compatible object
        end_point: end point as :class:`Vec2` compatible object
        bulge: bulge value

    )r/   r-   r6   s      r   r
   r
   ”   s   € ô Ô" ;°	¸5ÓAÓBÐBr   c                ó”   — 	 |d| z  z  }	 |dt        j                  d||z  z
  «      z   z  S # t         $ r Y yw xY w# t        $ r Y yw xY w)zúReturns the bulge value for the given arc radius and chord length.
    Returns 0 if the radius is zero or the radius is too small for the given
    chord length to create an arc.

    Args:
        radius: arc radius
        chord: chord length

    r3   g        r5   )ÚZeroDivisionErrorr   ÚsqrtÚ
ValueError)r$   ÚchordÚxs      r   r   r   ¢   sb   € ðØ�S˜6‘\Ñ"ˆðØ�Cœ$Ÿ)™) C¨!¨a©%¡KÓ0Ñ0Ñ1Ð1øô ò Ùðûô ò Ùðús   ‚, ‹ ; ¬	8·8»	AÁAc                ó2   — t        j                  | dz  «      S )zeReturns the bulge value for the given arc angle.

    Args:
        angle: arc angle in radians

    r   )r   Útan)r   s    r   r   r   ·   s   € ô �8‰8�E˜C‘KÓ Ð r   )r   r   r   Úfloatr   r@   Úreturnr   )r   r   r   r   rA   r@   )
r!   r   r"   r@   r#   r@   r$   r@   rA   ztuple[Vec2, Vec2, float])r%   r   r&   r   r+   r   rA   r@   )r%   r   r&   r   r)   r@   rA   z tuple[Vec2, float, float, float])r%   r   r&   r   r)   r@   rA   r   )r%   r   r&   r   r)   r@   rA   r@   )r$   r@   r<   r@   rA   r@   )r   r@   rA   r@   )Ú
__future__r   Útypingr   r   Ú
ezdxf.mathr   r   Ú__all__r   r   r   r   r   r	   r-   r
   r   r   © r   r   Ú<module>rG      s»   ðõ
 #Ý Û ß !ò€ó	6ó'ð)Øð)Ø$ð)Ø16ð)Ø@Eð)àó)ó.%ð EØð EØ"&ð EØ/4ð Eà%ó EóFð&ØðØ"&ðØ/4ðà
óóCóô*!r   