Ë
    £èhÛT  ã                  ó^  — d dl mZ d dlmZmZmZ d dlZd dlZd dl	m
Z
mZmZmZmZmZmZmZmZmZ erd dlmZ d dlmZ g d¢Zd ej2                  dz  ej2                  ej2                  d	z  gZej2                  d
z  Z G 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)ÚTYPE_CHECKINGÚIterableÚAnyN)
ÚVec3ÚUVecÚNULLVECÚX_AXISÚZ_AXISÚOCSÚMatrix44Úarc_angle_span_radÚdistance_point_line_3dÚenclosing_angles)Ú
BaseLayout©ÚEllipse)ÚConstructionEllipseÚangle_to_paramÚparam_to_angleÚrytz_axis_constructionç      à?g      ø?ç       @c                  ó(  — e Zd ZdZeeeddej                  df	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	e
ededddf	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Zd„ Zedd	„«       Zedd
„«       Zdd„Zdd„Zdd„Zedd„«       Zdd„Zd d„Zd!d"d„Zd#d„Zd d„Zd$d„Zd%d&d„Zd'd„Zy)(r   a‡  Construction tool for 3D ellipsis.

    Args:
        center: 3D center point
        major_axis: major axis as 3D vector
        extrusion: normal vector of ellipse plane
        ratio: ratio of minor axis to major axis
        start_param: start param in radians
        end_param: end param in radians
        ccw: is counter-clockwise flag - swaps start- and end param if ``False``

    é   r   Tc                ó  — t        |«      | _        t        |«      | _        | j                  j                  t        «      rt        d«      ‚t        |«      | _        | j                  j                  t        «      rt        d«      ‚t        |«      | _        t        |«      | _	        t        |«      | _
        |s#| j                  | j                  c| _	        | _
        t        | j                  | j                  | j                  «      | _        y )Nz!Invalid major axis (null vector).z'Invalid extrusion vector (null vector).)r   ÚcenterÚ
major_axisÚiscloser	   Ú
ValueErrorÚ	extrusionÚfloatÚratioÚstart_paramÚ	end_paramÚ
minor_axis)Úselfr   r   r!   r#   r$   r%   Úccws           ú2lib/python3.12/site-packages/ezdxf/math/ellipse.pyÚ__init__zConstructionEllipse.__init__1   sÀ   € ô ˜6“lˆŒÜ˜zÓ*ˆŒØ�?‰?×"Ñ"¤7Ô+ÜÐ@ÓBÐBÜ˜i›ˆŒØ�?‰?×"Ñ"¤7Ô+ÜÐFÓHÐHÜ˜5“\ˆŒ
Ü  Ó-ˆÔÜ˜yÓ)ˆŒÙØ/3¯~©~¸t×?OÑ?OÐ,ˆDÔ˜dœnÜ$ T§_¡_°d·n±nÀdÇjÁjÓQˆ�ó    ih  c                óf  — t        |«      }t        j                  |«      rt        dt	        |«      › �«      ‚d}t        |«      }|j                  |«      }|j                  t        |dd«      «      }	t        j                  |«      }
t        j                  |«      } | ||	|||
|t        |«      «      S )a¬  Returns :class:`ConstructionEllipse` from arc or circle.

        Arc and Circle parameters defined in OCS.

        Args:
             center: center in OCS
             radius: arc or circle radius
             extrusion: OCS extrusion vector
             start_angle: start angle in degrees
             end_angle: end angle in degrees
             ccw: arc curve goes counter clockwise from start to end if ``True``
        zInvalid extrusion: ç      ð?r   )Úabsr	   r   r    Ústrr   Úto_wcsr   ÚmathÚradiansÚbool)Úclsr   Úradiusr!   Ústart_angleÚ	end_angler(   r#   Úocsr   r$   r%   s               r)   Úfrom_arczConstructionEllipse.from_arcI   s¦   € ô, �V“ˆÜ�?‰?˜9Ô%ÜÐ2´3°y³>Ð2BÐCÓDÐDØˆÜ�)‹nˆØ—‘˜FÓ#ˆà—Z‘Z¤ V¨Q°Ó 2Ó3ˆ
ä—l‘l ;Ó/ˆÜ—L‘L Ó+ˆ	ÙØØØØØØÜ�‹Ió
ð 	
r+   c                ó¦   — | j                  | j                  | j                  | j                  | j                  | j
                  | j                  «      S ©N)Ú	__class__r   r   r!   r#   r$   r%   ©r'   s    r)   Ú__copy__zConstructionEllipse.__copy__t   s?   € Ø�~‰~Ø�K‰KØ�O‰OØ�N‰NØ�J‰JØ×ÑØ�N‰Nó
ð 	
r+   c                ó„   — t        | j                  | j                  | j                  | j                  | j
                  «      S )z'Returns start point of ellipse as Vec3.)Úvertexr$   r   r&   r   r#   r=   s    r)   Ústart_pointzConstructionEllipse.start_point~   s6   € ô Ø×ÑØ�O‰OØ�O‰OØ�K‰KØ�J‰Jó
ð 	
r+   c                ó„   — t        | j                  | j                  | j                  | j                  | j
                  «      S )z%Returns end point of ellipse as Vec3.)r@   r%   r   r&   r   r#   r=   s    r)   Ú	end_pointzConstructionEllipse.end_point‰   s4   € ô Ø�N‰NØ�O‰OØ�O‰OØ�K‰KØ�J‰Jó
ð 	
r+   c                ó  — | j                   dkD  r!| j                  «       }|j                  «        n| }|j                  |j                  |j
                  t        |j                   d«      |j                  |j                  dœS )z‰Returns required DXF attributes to build an ELLIPSE entity.

        Entity ELLIPSE has always a ratio in range from 1e-6 to 1.

        r   ç�íµ ÷Æ°>)r   r   r!   r#   r$   r%   )	r#   r>   Ú	swap_axisr   r   r!   Úmaxr$   r%   )r'   Úes     r)   Ú
dxfattribszConstructionEllipse.dxfattribs”   sc   € ð �:‰:˜Š>Ø—‘“ˆAØ�K‰K�MàˆAà—h‘hØŸ,™,ØŸ™Ü˜Ÿ™ $Ó'ØŸ=™=ØŸ™ñ
ð 	
r+   c              #  óà   K  — | j                   }| j                  }t        D ]I  }t        |||«      sŒt	        || j
                  | j                  | j                  | j                  «      –— ŒK y­w)zZYields main axis points of ellipse in the range from start- to end
        param.
        N)	r$   r%   ÚQUARTER_PARAMSr   r@   r   r&   r   r#   )r'   ÚstartÚendÚparams       r)   Úmain_axis_pointsz$ConstructionEllipse.main_axis_points¨   s^   è ø€ ð × Ñ ˆØ�n‰nˆß#ˆEÜ  u¨cÕ2ÜØØ—O‘OØ—O‘OØ—K‘KØ—J‘Jóó ñ $ùs
   ‚/A.²<A.c           	     óÂ  ‡‡‡— |j                  | j                  «      }| j                  x}}| j                  x}}t	        | j
                  | j                  | j                  «      }|j                  | j
                  |f«      \  }}	|j                  «       j                  |	j                  «       «      }
t        |
«      dkD  r2t        ||	«      \  }}	Š|j                  |	«      j                  «       }d}nG|	j                  |j                  z  Š|j                  |	«      j                  «       }t	        ||‰«      }	d}|�r´t        j                   ||d¬«      �s›|j                  «       Š|	j                  «       Š||z
  t        j"                  z  }dˆˆˆfd„}|j                  t%        || j
                  || j                  | j                  «      «      }|j                  t%        || j
                  || j                  | j                  «      «      } |||z
  «      } |||z
  «      }t        j                   |t        j&                  d¬«      s3||z
  t        j"                  z  }t        j                   ||d¬«      s{||}}nv|j                  t%        t)        ||«      | j
                  || j                  | j                  «      «      }t%        t)        ||«      ||	|‰«      }|j!                  |d¬«      s||}}‰dkD  rkt	        ||‰«      }d‰z  Št	        ||‰«      }	t        j                   |d	«      r$t        j                   |t        j"                  «      s|t*        z  }|t*        z  }|t        j"                  z  }|t        j"                  z  }t        j                   ||«      rd
}t        j"                  }|| _        || _        |	| _        || _        ‰| _        || _        || _        y)z8Transform ellipse in place by transformation matrix `m`.rE   TFç•Ö&è.>©Úabs_tolc                óœ   •— ‰j                  | «      ‰z  }‰j                  | «      }t        j                  ||«      t        j                  z  S r;   )Údotr1   Úatan2Útau)ÚvecÚdyÚdxÚ	new_ratioÚx_axisÚy_axiss      €€€r)   rN   z,ConstructionEllipse.transform.<locals>.paramÛ   s<   ø€ Ø—Z‘Z “_ yÑ0�Ø—Z‘Z “_�Ü—z‘z " bÓ)¬D¯H©HÑ4Ð4r+   r   r-   r   ç        N)rX   z'Vec3'Úreturnr"   )Ú	transformr   r$   r%   r&   r   r!   r#   Útransform_directionsÚ	normalizerU   r.   r   ÚcrossÚ	magnituder1   r   rW   r@   ÚpiÚ	mid_paramÚHALF_PI)r'   ÚmÚ
new_centerÚold_start_paramr$   Úold_end_paramr%   Úold_minor_axisÚnew_major_axisÚnew_minor_axisÚdot_productÚnew_extrusionÚadjust_paramsÚold_param_spanrN   rA   rC   Únew_param_spanÚold_chk_pointÚnew_chk_pointr[   r\   r]   s                       @@@r)   r`   zConstructionEllipse.transform¸   sp  ú€ à—[‘[ §¡Ó-ˆ
à(,×(8Ñ(8Ð8ˆ˜+Ø$(§N¡NÐ2ˆ˜	Ü# D§O¡O°T·^±^ÀTÇZÁZÓPˆØ)*×)?Ñ)?Ø�_‰_˜nÐ-ó*
Ñ&ˆ˜ð %×.Ñ.Ó0×4Ñ4°^×5MÑ5MÓ5OÓPˆÜˆ{Ó˜dÒ"Ü8NØ ó9Ñ5ˆN˜N¨Ið +×0Ñ0°Ó@×JÑJÓLˆMØ ‰Mð '×0Ñ0°>×3KÑ3KÑKˆIà*×0Ñ0°Ó@×JÑJÓLˆMä'¨¸ÀyÓQˆNØ!ˆMâ¤§¡¨k¸9ÈdÖ!Sà#×-Ñ-Ó/ˆFØ#×-Ñ-Ó/ˆFð (¨+Ñ5¼¿¹ÑAˆN÷5ð Ÿ+™+ÜØØ—O‘OØ"Ø—K‘KØ—J‘JóóˆKð Ÿ™ÜØØ—O‘OØ"Ø—K‘KØ—J‘JóóˆIñ   ¨jÑ 8Ó9ˆKÙ˜i¨*Ñ4Ó5ˆIô —<‘< ´·±ÀÕFð
 #,¨kÑ"9¼T¿X¹XÑ!E�Ü—|‘| N°NÈDÕQØ-6¸ ‘Kð !"§¡ÜÜ! /°=ÓAØŸ™Ø&ØŸ™ØŸ
™
óó!�ô !'Ü˜k¨9Ó5Ø"Ø"ØØó!�ð %×,Ñ,¨]ÀDÐ,ÔIØ-6¸ �Kà�qŠ=Ü'¨¸ÀyÓQˆNØ˜i™ˆIÜ'¨¸ÀyÓQˆNÜ—L‘L ¨aÔ0´T·\±\À)ÌTÏXÉXÔ5VØœwÑ&�ØœWÑ$�	ð "¤D§H¡HÑ,ˆØ¤§¡Ñ(ˆ	Ü�<‰<˜ YÔ/ØˆKÜŸ™ˆIà ˆŒØ(ˆŒØ(ˆŒØ&ˆŒØˆŒ
Ø&ˆÔØ"ˆ�r+   c                óB   — t        | j                  | j                  «      S )zšReturns the counter-clockwise params span from start- to end param,
        see also :func:`ezdxf.math.ellipse_param_span` for more information.

        )r   r$   r%   r=   s    r)   Ú
param_spanzConstructionEllipse.param_span-  s   € ô " $×"2Ñ"2°D·N±NÓCÐCr+   c              #  ób   K  — t        | j                  | j                  |«      E d{  –—†  y7 Œ­w)uš   Returns `num` params from start- to end param in counter-clockwise
        order.

        All params are normalized in the range from [0, 2Ï€).

        N)Ú
get_paramsr$   r%   )r'   Únums     r)   ÚparamszConstructionEllipse.params5  s$   è ø€ ô ˜d×.Ñ.°·±ÀÓD×DÒDús   ‚%/§-¨/c              #  óh  K  — | j                   }| j                  }| j                  j                  «       }| j                  j                  «       }| j                  j
                  }||z  }|D ]B  }t        j                  |«      |z  |z  }	t        j                  |«      |z  |z  }
||	z   |
z   –— ŒD y­w)u  Yields vertices on ellipse for iterable `params` in WCS.

        Args:
            params: param values in the range from [0, 2Ï€) in radians,
                param goes counter-clockwise around the extrusion vector,
                major_axis = local x-axis = 0 rad.

        N)	r   r#   r   rb   r&   rd   r1   ÚcosÚsin)r'   r{   r   r#   r\   r]   Úradius_xÚradius_yrN   ÚxÚys              r)   ÚverticeszConstructionEllipse.vertices>  s�   è ø€ ð —‘ˆØ—
‘
ˆØ—‘×*Ñ*Ó,ˆØ—‘×*Ñ*Ó,ˆØ—?‘?×,Ñ,ˆØ˜eÑ#ˆãˆEÜ—‘˜“ (Ñ*¨VÑ3ˆAÜ—‘˜“ (Ñ*¨VÑ3ˆAØ˜1‘*˜q‘.Ó ñ ùs   ‚B0B2c              #  ó  ‡ ‡‡	‡
‡‡‡‡K  — dˆ	ˆ
ˆ ˆˆfd„Šdˆˆˆfd„Š‰ j                   j                  «       Š‰ j                  j                  «       Š‰ j                   j                  Š	‰	‰ j                  z  Š
‰ j
                  |z  }|dk(  ry‰ j                  t        j                  z  }t        j                  ‰ j                  t        j                  «      rt        j                  }n‰ j                  t        j                  z  }t        j                  ||«      ry||kD  r|t        j                  z  } ‰|«      }|–— ||k  rC||z   }t        j                  ||«      r|} ‰|«      } ‰||||«      E d{  –—†  |}|}||k  rŒByy7 Œ­w)a  Adaptive recursive flattening. The argument `segments` is the
        minimum count of approximation segments, if the distance from the center
        of the approximation segment to the curve is bigger than `distance` the
        segment will be subdivided. Returns a closed polygon for a full ellipse:
        start vertex == end vertex.

        Args:
            distance: maximum distance from the projected curve point onto the
                segment chord.
            segments: minimum segment count

        c                ó”   •— t        j                  | «      ‰z  ‰z  }t        j                  | «      ‰z  ‰z  }‰j                  |z   |z   S r;   )r1   r}   r~   r   )Úpr�   r‚   r   r€   r'   r\   r]   s      €€€€€r)   Úvertex_z/ConstructionEllipse.flattening.<locals>.vertex_a  sD   ø€ Ü—‘˜“˜hÑ&¨Ñ/ˆAÜ—‘˜“˜hÑ&¨Ñ/ˆAØ—;‘; ‘? QÑ&Ð&r+   c              3  ó°   •K  — ||z   dz  } ‰	|«      }t        || |«      }|‰k  r|–— y  ‰| |||«      E d {  –—†   ‰||||«      E d {  –—†  y 7 Œ7 Œ­w)Nr   )r   )
ÚsrH   Ús_paramÚe_paramÚm_paramrh   ÚdÚdistanceÚsubdivr‡   s
          €€€r)   r�   z.ConstructionEllipse.flattening.<locals>.subdivf  sk   øè ø€ Ø Ñ(¨CÑ/ˆGÙ˜Ó ˆAÜ& q¨!¨QÓ/ˆAØ�8Š|Ø“á! ! Q¨°Ó9×9Ð9Ù! ! Q¨°Ó9×9Ñ9ð :øØ9ús!   ƒ6A¹AºAÁAÁAÁAr^   N)r†   r"   r_   r   )r‰   r   rH   r   rŠ   r"   r‹   r"   )r   rb   r&   rd   r#   rw   r$   r1   rW   r   r%   )r'   rŽ   ÚsegmentsÚdeltarN   r%   rA   Únext_end_paramrC   r   r€   r�   r‡   r\   r]   s   ``       @@@@@@r)   Ú
flatteningzConstructionEllipse.flatteningS  sH  ÿè ø€ ÷	'ñ 	'÷
	:ð —‘×*Ñ*Ó,ˆØ—‘×*Ñ*Ó,ˆØ—?‘?×,Ñ,ˆØ˜dŸj™jÑ(ˆà—‘ (Ñ*ˆØ�CŠ<Øà× Ñ ¤4§8¡8Ñ+ˆÜ�<‰<˜Ÿ™¬¯©Ô1ÜŸ™‰IàŸ™¬¯©Ñ1ˆIä�<‰<˜˜yÔ)ØØ�YÒØœŸ™Ñ!ˆIá˜e“nˆØÒØ�iÒØ" U™]ˆNÜ�|‰|˜N¨IÔ6Ø!*�Ù Ó/ˆIÙ˜k¨9°e¸^ÓL×LÐLØ"ˆEØ#ˆKð �iÕð
 Mús   ŠE-F
Å7FÅ8F
ÆF
c              #  óv  K  — | j                   j                  «       }| j                  j                  «       }| j                  }| j                  }t        j                  |«      D ]Q  }||z  }t        j                  |j                  |«      |z  |j                  |«      «      t        j                  z  –— ŒS y­w)u8  Yields ellipse params for all given `vertices`.

        The vertex don't have to be exact on the ellipse curve or in the range
        from start- to end param or even in the ellipse plane. Param is
        calculated from the intersection point of the ray projected on the
        ellipse plane from the center of the ellipse through the vertex.

        .. warning::

            An input for start- and end vertex at param 0 and 2Ï€ return
            unpredictable results because of floating point inaccuracy,
            sometimes 0 and sometimes 2Ï€.

        N)r   rb   r&   r#   r   r   Úgenerater1   rV   rU   rW   )r'   rƒ   r\   r]   r#   r   Úvs          r)   Úparams_from_verticesz(ConstructionEllipse.params_from_vertices�  s‰   è ø€ ð —‘×*Ñ*Ó,ˆØ—‘×*Ñ*Ó,ˆØ—
‘
ˆØ—‘ˆÜ—‘˜xÖ(ˆAØ�‰KˆAÜ—*‘*˜VŸZ™Z¨›]¨UÑ2°F·J±J¸q³MÓBÄTÇXÁXÑMÓMñ )ùs   ‚B7B9c              #  ó,  K  — | j                   }| j                  j                  «       }| j                  j                  «       }|D ]K  }t	        j
                  |«       |z  }t	        j                  |«      |z  |z  }||z   j                  «       –— ŒM y­w)u3  Yields tangents on ellipse for iterable `params` in WCS as direction
        vectors.

        Args:
            params: param values in the range from [0, 2Ï€] in radians, param
                goes counter-clockwise around the extrusion vector,
                major_axis = local x-axis = 0 rad.

        N)r#   r   rb   r&   r1   r~   r}   )r'   r{   r#   r\   r]   rN   r�   r‚   s           r)   ÚtangentszConstructionEllipse.tangents¦  s~   è ø€ ð —
‘
ˆØ—‘×*Ñ*Ó,ˆØ—‘×*Ñ*Ó,ˆãˆEÜ—‘˜%“Ð  6Ñ)ˆAÜ—‘˜“ %Ñ'¨&Ñ0ˆAØ�q‘5×#Ñ#Ó%Ó%ñ ùs   ‚BBc                óè  — | j                   | _        d| j                  z  }t        |d«      | _        t        | j                  | j                  | j                  «      | _         | j
                  }| j                  }t        j                  |d«      r%t        j                  |t        j                  «      ry|t        z
  t        j                  z  | _        |t        z
  t        j                  z  | _        y)z.Swap axis and adjust start- and end parameter.r-   rE   r   N)r&   r   r#   rG   r!   r$   r%   r1   r   rW   rg   )r'   r#   r$   r%   s       r)   rF   zConstructionEllipse.swap_axis¹  s¦   € àŸ/™/ˆŒØ�d—j‘jÑ ˆÜ˜ Ó%ˆŒ
Ü$ T§_¡_°d·n±nÀdÇjÁjÓQˆŒà×&Ñ&ˆØ—N‘Nˆ	Ü�<‰<˜ QÔ'¬D¯L©L¸ÄDÇHÁHÔ,MØØ'¬'Ñ1´T·X±XÑ=ˆÔØ#¤gÑ-´·±Ñ9ˆ�r+   Nc                óÌ   — ddl m} t        |xs i «      }|j                  | j	                  «       «        |j
                  ||j                  ¬«      }|j                  |«       |S )a  Add ellipse as DXF :class:`~ezdxf.entities.Ellipse` entity to a
        layout.

        Args:
            layout: destination layout as :class:`~ezdxf.layouts.BaseLayout`
                object
            dxfattribs: additional DXF attributes for the ELLIPSE entity

        r   r   )rI   Údoc)Úezdxf.entitiesr   ÚdictÚupdaterI   Únewrœ   Ú
add_entity)r'   ÚlayoutrI   r   rH   s        r)   Úadd_to_layoutz!ConstructionEllipse.add_to_layoutÇ  sT   € õ 	+ä˜*Ò*¨Ó+ˆ
Ø×Ñ˜$Ÿ/™/Ó+Ô,ØˆG�K‰K :°6·:±:Ô>ˆØ×Ñ˜!ÔØˆr+   c                ó  — t        | j                  «      }| j                  |j                  | j                  «      |j                  | j
                  «      j                  d¬«      | j                  | j                  | j                  ¬«      S )zqReturns ellipse parameters as OCS representation.

        OCS elevation is stored in :attr:`center.z`.

        r^   )Úz)r   r   r#   r$   r%   )
r   r!   r<   Úfrom_wcsr   r   Úreplacer#   r$   r%   )r'   r8   s     r)   Úto_ocszConstructionEllipse.to_ocsÙ  sm   € ô �$—.‘.Ó!ˆØ�~‰~Ø—<‘< §¡Ó,Ø—|‘| D§O¡OÓ4×<Ñ<¸sÐ<ÓCØ—*‘*Ø×(Ñ(Ø—n‘nð ó 
ð 	
r+   )r   r   r   r   r!   r   r#   r"   r$   r"   r%   r"   r(   r3   )r   r   r5   r"   r!   r   r6   r"   r7   r"   r(   r3   r_   r   )r_   r   )r_   zdict[str, Any])r_   úIterable[Vec3])rh   r   r_   ÚNone)r_   r"   )rz   Úintr_   úIterable[float])r{   r¬   r_   r©   )é   )rŽ   r"   r�   r«   r_   r©   )rƒ   zIterable[UVec]r_   r¬   )r_   rª   r;   )r¢   r   r_   r   )r_   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r
   r   r1   rW   r*   Úclassmethodr9   r>   ÚpropertyrA   rC   rI   rO   r`   rw   r{   rƒ   r“   r—   r™   rF   r£   r¨   © r+   r)   r   r   #   s_  „ ñð Ø!Ø ØØØŸ8™8ØðRàðRð ðRð ð	Rð
 ðRð ðRð ðRð óRð0 ð ØØ ØØØð(
àð(
ð ð(
ð ð	(
ð
 ð(
ð ð(
ð ð(
ð 
ò(
ó ð(
òT
ð ò
ó ð
ð ò
ó ð
ó
ó(ó s#ðj òDó ðDóEó!ô*:$óxNó.&ó&:ôô$
r+   r   c                óB   — || k  r|t         j                  z  }| |z   dz  S )Nr   )r1   rW   )rL   rM   s     r)   rf   rf   é  s%   € Ø
ˆU‚{ØŒt�x‰x‰ˆØ�C‰K˜3ÑÐr+   c                ó\   — |j                  | «      j                  | j                  |z  «      S r;   )rc   rb   rd   )r   r!   r#   s      r)   r&   r&   ï  s'   € Ø�?‰?˜:Ó&×0Ñ0°×1EÑ1EÈÑ1MÓNÐNr+   c                óà   — |j                  «       }|j                  «       }|j                  }||z  }t        j                  | «      |z  |z  }	t        j                  | «      |z  |z  }
||	z   |
z   S r;   )rb   rd   r1   r}   r~   )rN   r   r&   r   r#   r\   r]   r   r€   r�   r‚   s              r)   r@   r@   ó  sq   € ð ×!Ñ!Ó#€FØ×!Ñ!Ó#€FØ×#Ñ#€HØ˜%Ñ€HÜ�‰�‹˜(Ñ" VÑ+€AÜ�‰�‹˜(Ñ" VÑ+€AØ�A‰:˜‰>Ðr+   c              #  ó¾   K  — |dk  rt        d«      ‚|| k  r|t        j                  z  }t        j                  | ||«      D ]  }|t        j                  z  –— Œ y­w)uŠ   Returns `num` params from start- to end param in counter-clockwise order.

    All params are normalized in the range from [0, 2Ï€).

    é   znum >= 2N)r    r1   rW   ÚnpÚlinspace)rL   rM   rz   rN   s       r)   ry   ry   ÿ  sT   è ø€ ð ˆQ‚wÜ˜Ó$Ð$Ø
ˆe‚|ØŒt�x‰x‰ˆä—‘˜U C¨Ö-ˆØ”d—h‘hÑÓñ .ùs   ‚AAc                ó¢   — t        j                  t        j                  |«      | z  t        j                  |«      «      t         j                  z  S )uK  Returns ellipse parameter for argument `angle`.

    Args:
        ratio: minor axis to major axis ratio as stored in the ELLIPSE entity
            (always <= 1).
        angle: angle between major axis and line from center to point on the
            ellipse

    Returns:
        the ellipse parameter in the range [0, 2Ï€)
    )r1   rV   r~   r}   rW   )r#   Úangles     r)   r   r     s3   € ô �:‰:”d—h‘h˜u“o¨Ñ-¬t¯x©x¸«Ó?Ä$Ç(Á(ÑJÐJr+   c                ó€   — t        j                  t        j                  |«      | z  t        j                  |«      «      S )uV  Returns circle angle from ellipse parameter for argument `angle`.

    Args:
        ratio: minor axis to major axis ratio as stored in the ELLIPSE entity
            (always <= 1).
        param: ellipse parameter between major axis and point on the ellipse
            curve

    Returns:
        the circle angle in the range [0, 2Ï€)
    )r1   rV   r~   r}   )r#   rN   s     r)   r   r     s*   € ô �:‰:”d—h‘h˜u“o¨Ñ-¬t¯x©x¸«Ó?Ð?r+   c                ó0  — t        | «      }t        j                  | j                  dd¬«      r>t        j                  |j                  dd¬«      rt        |«      j	                  d¬«      }n;| j                  |«      }|j                  |«      j                  |j                  «      }|j                  |«      }|j                  }||z
  j                  |«      }||z
  }||z   }	|j                  t        «      s|	j                  t        «      rt        d«      ‚||z
  j                  }
|	|z
  j                  }t        j                  |
d«      st        j                  |d«      rt        d«      ‚||
z  }|	j                  |
«      }|j                  |«      }|||fS )uÄ  The Rytzâ€™s axis construction is a basic method of descriptive Geometry
    to find the axes, the semi-major axis and semi-minor axis, starting from two
    conjugated half-diameters.

    Source: `Wikipedia <https://en.m.wikipedia.org/wiki/Rytz%27s_construction>`_

    Given conjugated diameter `d1` is the vector from center C to point P and
    the given conjugated diameter `d2` is the vector from center C to point Q.
    Center of ellipse is always ``(0, 0, 0)``. This algorithm works for
    2D/3D vectors.

    Args:
        d1: conjugated semi-major axis as :class:`Vec3`
        d2: conjugated semi-minor axis as :class:`Vec3`

    Returns:
         Tuple of (major axis, minor axis, ratio)

    r   rQ   rR   F)r(   z.Conjugated axis required, invalid source data.r^   )r   r1   r   r¥   Ú
orthogonalrc   rb   rd   Úlerpr	   ÚArithmeticError)Úd1Úd2ÚQÚP1r!   ÚDr5   Úradius_vectorÚAÚBÚmajor_axis_lengthÚminor_axis_lengthr#   r   r&   s                  r)   r   r   ,  sU  € ô( 	ˆR‹€Aä‡|�|�B—D‘D˜! TÕ*¬t¯|©|¸B¿D¹DÀ!ÈTÕ/Rä�"‹X× Ñ  UÐ Ó+‰à—H‘H˜R“Lˆ	Ø�_‰_˜RÓ ×*Ñ*¨2¯<©<Ó8ˆà
�‰�‹
€AØ�[‰[€FØ˜‘V×&Ñ& vÓ.€MØ	ˆMÑ€AØ	ˆMÑ€AØ‡y�y”Ô˜QŸY™Y¤wÔ/ÜÐNÓOÐOØ˜Q™×)Ñ)ÐØ˜Q™×)Ñ)ÐÜ‡|�|Ð% sÔ+¬t¯|©|Ð<MÈsÔ/SÜÐNÓOÐOØÐ 1Ñ1€EØ—‘Ð.Ó/€JØ—‘Ð.Ó/€JØ�z 5Ð(Ð(r+   )rL   r"   rM   r"   r_   r"   )r   r   r!   r   r#   r"   r_   r   )rN   r"   r   r   r&   r   r   r   r#   r"   r_   r   )rL   r"   rM   r"   rz   r«   r_   r¬   )r#   r"   r½   r"   r_   r"   )r#   r"   rN   r"   r_   r"   )rÃ   r   rÄ   r   r_   ztuple[Vec3, Vec3, float])$Ú
__future__r   Útypingr   r   r   Únumpyrº   r1   Ú
ezdxf.mathr   r   r	   r
   r   r   r   r   r   r   Úezdxf.layoutsr   r�   r   Ú__all__re   rK   rg   r   rf   r&   r@   ry   r   r   r   r´   r+   r)   Ú<module>rÓ      sË   ðõ #ß /Ñ /Û ã ÷÷ ÷ ñ Ý(Ý&ò€ð �T—W‘W˜s‘] D§G¡G¨T¯W©W°s©]Ð;€Ø
�'‰'�C‰-€÷C
ñ C
óLóOð	Øð	Ø"ð	Ø04ð	Ø>Bð	ØKPð	à	ó	óóKó@ô+)r+   