
    Og                    H   d dl mZ d dlmZmZ d dlZd dlZd dlm	Z	m
Z
mZmZ d dlmZ d dlmZmZmZmZmZ d dlmZmZ dd	lmZ dd
lmZ ddlmZmZmZ ddl m!Z! erd dl"m#Z# dgZ$ ed edd        edd      d      Z% ee%      Z& eee&      Z'e! G d de             Z(y)    )annotations)TYPE_CHECKINGIteratorN)Vec3Matrix44ConstructionArcarc_angle_span_deg)OCSTransform)DXFAttrDXFAttributesDefSubclassgroup_code_mappingmerge_group_code_mappings)DXF12SUBCLASS_MARKER   )
base_class)acdb_entity)acdb_circleCirclemerged_circle_group_codes)register_entity)AbstractTagWriterArcAcDbArc2   )default3   h  )start_angle	end_anglec                       e Zd ZdZdZ eeeee	      Z
eZd fdZedd       Zedd       ZddZddZd fdZdd	Zdd
Z xZS )r   zDXF ARC entityARCc                    t         |   |       |j                  t        kD  r$|j	                  t
        t        j                         | j                  j                  |ddg       y)z(Export entity specific data as DXF tags.r    r!   N)
superexport_entity
dxfversionr   
write_tag2r   acdb_arcnamedxfexport_dxf_attribs)self	tagwriter	__class__s     W/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/entities/arc.pyr&   zArc.export_entity8   sM    i( %'  (--@##I{/KL    c                j    t        | j                  | j                  j                  g            }|d   S )zeReturns the start point of the arc in :ref:`WCS`, takes the :ref:`OCS` into
        account.
        r   )listverticesr+   r    r-   vs     r0   start_pointzArc.start_pointA   s-    
  4 4567tr1   c                j    t        | j                  | j                  j                  g            }|d   S )zcReturns the end point of the arc in :ref:`WCS`, takes the :ref:`OCS` into
        account.
        r   )r3   r4   r+   r!   r5   s     r0   	end_pointzArc.end_pointI   s-    
  2 2345tr1   c              #     K   |dk  rt        d      | j                  j                  dz  }| j                  j                  dz  }||k  r|dz  }t	        j
                  |||d      D ]	  }|dz    yw)zYields `num` angles from start- to end angle in degrees in counter-clockwise
        orientation. All angles are normalized in the range from [0, 360).
           znum >= 2r   T)numendpointN)
ValueErrorr+   r    r!   nplinspace)r-   r<   startstopangles        r0   anglesz
Arc.anglesQ   sz      7Z(($$s*xx!!C'5=CKD[[#E 	E#+	s   A3A5c              #  F  K   | j                         }| j                         }t        | j                  j                        j
                  |j                  r|j                  }nt        j                  } |fd|j                  |      D              E d{    y7 w)a  Approximate the arc by vertices in :ref:`WCS`, the argument `sagitta`_
        defines the maximum distance from the center of an arc segment to the center of
        its chord.

        .. _sagitta: https://en.wikipedia.org/wiki/Sagitta_(geometry)
        c              3  `   K   | ]%  }t        |j                  |j                         ' y w)N)r   xy).0p	elevations     r0   	<genexpr>z!Arc.flattening.<locals>.<genexpr>m   s"     U$qssACC3Us   +.N)
construction_toolocsr   r+   centerz	transformpoints_to_wcsgenerate
flattening)r-   sagittaarcrN   to_wcsrK   s        @r0   rT   zArc.flattening^   sr      $$&hhj)++	==&&F]]FUS^^G=TUUUUs   BB!BB!c                   t        | j                  j                  |      }t        |   |       | j                  j
                  }| j                  j                  }t        j                  t        ||      d      s3|j                  ||      \  | j                  _        | j                  _        | j                  |       | S )zTransform ARC entity by transformation matrix `m` inplace.
        Raises ``NonUniformScalingError()`` for non-uniform scaling.
        g     v@)r
   r+   	extrusionr%   
_transformr    r!   mathiscloser	   transform_ccw_arc_angles_degpost_transform)r-   mrN   ser/   s        r0   rQ   zArc.transformo   s     488--q1388''88%%||.q!4e< 00A6$"Ar1   c                    | j                   }t        |j                  |j                  |j                  |j
                        S )zzReturns the 2D construction tool :class:`ezdxf.math.ConstructionArc` but the
        extrusion vector is ignored.
        )r+   r   rO   radiusr    r!   )r-   r+   s     r0   rM   zArc.construction_tool   s6     hhJJJJOOMM	
 	
r1   c                    | j                   }t        |j                        |_        |j                  |_        |j                  |_        |j
                  |_        | S )zSet ARC data from the construction tool :class:`ezdxf.math.ConstructionArc`
        but the extrusion vector is ignored.
        )r+   r   rO   rc   r    r!   )r-   rV   r+   s      r0   apply_construction_toolzArc.apply_construction_tool   sC     hh#**%
ZZ
//r1   )r.   r   returnNone)rf   r   )r<   intrf   zIterator[float])rU   floatrf   zIterator[Vec3])r_   r   rf   r   )rf   r   )rV   r   rf   r   )__name__
__module____qualname____doc__DXFTYPEr   r   r   r   r)   
DXFATTRIBSmerged_arc_group_codesMERGED_GROUP_CODESr&   propertyr7   r9   rD   rT   rQ   rM   re   __classcell__)r/   s   @r0   r   r   0   si    Gz;XNJ/M    V" 

	r1   ))
__future__r   typingr   r   r[   numpyr?   
ezdxf.mathr   r   r   r	   ezdxf.math.transformtoolsr
   ezdxf.lldxf.attributesr   r   r   r   r   ezdxf.lldxf.constr   r   	dxfentityr   dxfgfxr   circler   r   r   factoryr   ezdxf.lldxf.tagwriterr   __all__r)   acdb_arc_group_codesrp   r    r1   r0   <module>r      s    # *    3  5 !  B B $7'r1-R- *(3 23 
 c& c cr1   