
    h@                        S SK Jr  S SKJrJrJrJrJr  S SKJ	r	J
r
JrJrJrJr  S SKJr  \(       a  S SKJr  / SQr\" SSS	5      4         SS
 jjrSr " S S5      r " S S5      r " S S\5      rg)    )annotations)TYPE_CHECKINGSequenceIterableOptionalIterator)Vec3UVecX_AXISY_AXISZ_AXISMatrix44)RGB)
BaseLayout)OCSUCSPassTroughUCS         c                P    [        X#5       H  u  pEU R                  XSU0S9  M     g )Ncolor)
dxfattribs)zipadd_line)layoutstartpointscolorspointr   s         @/var/www/html/env/lib/python3.13/site-packages/ezdxf/math/ucs.pyrender_axisr"      s*     F+'51AB ,    g      ?c                      \ rS rSrSr\4SS jjr\SS j5       r\SS j5       r	\SS j5       r
SS jrSS jrSS	 jrSS
 jrS\" SSS5      4       SS jjrSrg)r      z_Establish an :ref:`OCS` for a given extrusion vector.

Args:
    extrusion: extrusion vector.

c                   [        U5      R                  5       nUR                  [        5      (       + U l        U R                  (       a  [        UR                  5      [        :  a4  [        UR                  5      [        :  a  [        R                  " U5      nO[        R                  " U5      nUR                  5       nUR                  U5      R                  5       n[        R                  " X4U5      U l        g g N)r	   	normalizeiscloser   	transformabsx
_1_OVER_64yr   crossr   ucsmatrix)self	extrusionAzAxAys        r!   __init__OCS.__init__#   s    )_&&(ZZ//>>BDD	J&SY-C\\"%\\"%B"'')B",,rr2DK r#   c                \    U R                   (       a  U R                  R                  $ [        $ zx-axis unit vector)r*   r1   uxr   r2   s    r!   r;   OCS.ux/        "&t{{~~;V;r#   c                \    U R                   (       a  U R                  R                  $ [        $ zy-axis unit vector)r*   r1   uyr   r<   s    r!   rA   OCS.uy4   r>   r#   c                \    U R                   (       a  U R                  R                  $ [        $ zz-axis unit vector)r*   r1   uzr   r<   s    r!   rE   OCS.uz9   r>   r#   c                t    [        U5      nU R                  (       a  U R                  R                  U5      $ U$ )z#Returns OCS vector for WCS `point`.)r	   r*   r1   ocs_from_wcs)r2   r    p3s      r!   from_wcsOCS.from_wcs>   s,    %[>>;;++B//Ir#   c              #     #    [         R                  " U5      nU R                  (       a*  U R                  R                  nU H  nU" U5      v   M     gU Sh  vN   g N7f)z2Returns iterable of OCS vectors from WCS `points`.N)r	   generater*   r1   rH   )r2   r   _pointsrJ   r    s        r!   points_from_wcsOCS.points_from_wcsF   sH     --'>>{{//H uo% !    AA!AA!c                p    U R                   (       a  U R                  R                  U5      $ [        U5      $ )z#Returns WCS vector for OCS `point`.)r*   r1   
ocs_to_wcsr	   r2   r    s     r!   to_wcs
OCS.to_wcsP   s(    >>;;))%00;r#   c              #     #    [         R                  " U5      nU R                  (       a*  U R                  R                  nU H  nU" U5      v   M     gU Sh  vN   g N7f)z1Returns iterable of WCS vectors for OCS `points`.N)r	   rM   r*   r1   rS   )r2   r   rN   rU   r    s        r!   points_to_wcsOCS.points_to_wcsW   sH     --'>>[[++F Um# ! rQ   r   r   r   c           
         [        USU R                  [        U-  5      U R                  [        U-  5      U R                  [        U-  5      4US9  g)(Render axis as 3D lines into a `layout`.r   r   r   r   r   r   N)r"   rU   r   r   r   r2   r   lengthr   s       r!   r"   OCS.render_axisa   sL     	FVO,FVO,FVO,
 		
r#   r1   r*   N)r3   r
   returnr	   )r    r
   rc   r	   )r   zIterable[UVec]rc   Iterator[Vec3])r   r   r_   floatr   r   rc   None)__name__
__module____qualname____firstlineno____doc__r   r7   propertyr;   rA   rE   rJ   rO   rU   rX   r   r"   __static_attributes__ r#   r!   r   r      s     *0 
3 < < < < < < !Ql	

 
 	

 

 
r#   r   c                     \ rS rSrSr    S)       S*S jjr\S+S j5       r\S+S j5       r\S+S j5       r	\S+S j5       r
\
R                  S,S	 j5       r
S-S
 jrS.S jrS/S jrS0S jrS.S jrS/S jrS0S jrS.S jrS/S jrS1S jrS1S jrS2S jrS3S jrS4S jrS4S jrS4S jrS5S jrS6S jrS7S jr\S8S j5       r\         S9S j5       r!\         S9S j5       r"\         S9S  j5       r#\         S9S! j5       r$\         S9S" j5       r%\         S9S# j5       r&S$\'" S$S%S&5      4     S:S' jjr(S(r)g);r   t   a  Establish a user coordinate system (:ref:`UCS`). The UCS is defined by
the origin and two unit vectors for the x-, y- or z-axis, all axis in
:ref:`WCS`. The missing axis is the cross product of the given axis.

If x- and y-axis are ``None``: ux = ``(1, 0, 0)``, uy = ``(0, 1, 0)``,
uz = ``(0, 0, 1)``.

Unit vectors don't have to be normalized, normalization is done at
initialization, this is also the reason why scaling gets lost by copying or
rotating.

Args:
    origin: defines the UCS origin in world coordinates
    ux: defines the UCS x-axis as vector in :ref:`WCS`
    uy: defines the UCS y-axis as vector in :ref:`WCS`
    uz: defines the UCS z-axis as vector in :ref:`WCS`

Nc                P   Uc  Uc  [         n[        n[        nGOfUc\  [        U5      R	                  5       n[        U5      R	                  5       n[        U5      R                  U5      R	                  5       nGOUc[  [        U5      R	                  5       n[        U5      R	                  5       n[        U5      R                  U5      R	                  5       nOUc[  [        U5      R	                  5       n[        U5      R	                  5       n[        U5      R                  U5      R	                  5       nOK[        U5      R	                  5       n[        U5      R	                  5       n[        U5      R	                  5       n[        R                  " XVU[        U5      5      U l        g r'   )	r   r   r   r	   r(   r/   r   r0   r1   )r2   originr;   rA   rE   _ux_uy_uzs           r!   r7   UCS.__init__   s6    :"*CCCZr($$&Cr($$&Cr(..$..0CZr($$&Cr($$&Cr(..$..0CZr($$&Cr($$&Cr(..$..0Cr($$&Cr($$&Cr($$&C (SsDL Ir#   c                .    U R                   R                  $ r:   )r1   r;   r<   s    r!   r;   UCS.ux        {{~~r#   c                .    U R                   R                  $ r@   )r1   rA   r<   s    r!   rA   UCS.uy   ry   r#   c                .    U R                   R                  $ rD   )r1   rE   r<   s    r!   rE   UCS.uz   ry   r#   c                .    U R                   R                  $ )zReturns the originr1   rr   r<   s    r!   rr   
UCS.origin   s     {{!!!r#   c                $    XR                   l        g)zSet origin.Nr   )r2   vs     r!   rr   r      s     r#   c                n    [        U R                  U R                  U R                  U R                  5      $ )zReturns a copy of this UCS.)r   rr   r;   rA   rE   r<   s    r!   copyUCS.copy   s#    4;;$''::r#   c                8    U R                   R                  U5      $ )z"Returns WCS point for UCS `point`.ra   rT   s     r!   rU   
UCS.to_wcs   s    {{$$U++r#   c                8    U R                   R                  U5      $ )z1Returns iterable of WCS vectors for UCS `points`.)r1   transform_verticesr2   r   s     r!   rX   UCS.points_to_wcs   s    {{--f55r#   c                8    U R                   R                  U5      $ )zAReturns WCS direction for UCS `vector` without origin adjustment.)r1   transform_directionr2   vectors     r!   direction_to_wcsUCS.direction_to_wcs   s    {{..v66r#   c                8    U R                   R                  U5      $ )z"Returns UCS point for WCS `point`.)r1   ucs_vertex_from_wcsrT   s     r!   rJ   UCS.from_wcs   s    {{..u55r#   c              #  J   #    U R                   nU H  nU" U5      v   M     g7f)z2Returns iterable of UCS vectors from WCS `points`.N)rJ   )r2   r   rJ   r    s       r!   rO   UCS.points_from_wcs   s"     ==E5/! s   !#c                8    U R                   R                  U5      $ )z>Returns UCS vector for WCS `vector` without origin adjustment.)r1   ucs_direction_from_wcsr   s     r!   direction_from_wcsUCS.direction_from_wcs   s    {{11&99r#   c                l    U R                  U5      n[        U R                  5      R                  U5      $ )zeReturns OCS vector for UCS `point`.

The :class:`OCS` is defined by the z-axis of the :class:`UCS`.

rU   r   rE   rJ   )r2   r    wpoints      r!   to_ocs
UCS.to_ocs   s+     U#477|$$V,,r#   c              #     #    U R                   n[        U R                  5      nU H  nUR                  U" U5      5      v   M     g7f)zReturns iterable of OCS vectors for UCS `points`.

The :class:`OCS` is defined by the z-axis of the :class:`UCS`.

Args:
    points: iterable of UCS vertices

Nr   )r2   r   wcsocsr    s        r!   points_to_ocsUCS.points_to_ocs   s:      kk$''lE,,s5z** s   AAc                `    U R                  [        R                  " U5      5      R                  $ )zTransforms `angle` from current UCS to the parent coordinate system
(most likely the WCS) including the transformation to the OCS
established by the extrusion vector :attr:`UCS.uz`.

Args:
    angle: in UCS in degrees

)ucs_direction_to_ocs_directionr	   from_deg_angle	angle_degr2   angles     r!   to_ocs_angle_degUCS.to_ocs_angle_deg   s*     22&

)	r#   c                `    U R                  [        R                  " U5      5      R                  $ )zTransforms `angle` from current UCS to the parent coordinate system
(most likely the WCS) including the transformation to the OCS
established by the extrusion vector :attr:`UCS.uz`.

Args:
    angle: in UCS in radians

)r   r	   
from_angler   r   s     r!   to_ocs_angle_radUCS.to_ocs_angle_rad  s$     224??53IJPPPr#   c                h    [        U R                  5      R                  U R                  U5      5      $ )zTransforms UCS `direction` vector into OCS direction vector of the
parent coordinate system (most likely the WCS), target OCS is defined by
the UCS z-axis.
)r   rE   rJ   r   )r2   	directions     r!   r   "UCS.ucs_direction_to_ocs_direction  s(    
 477|$$T%:%:9%EFFr#   c                    [         R                  " [        U5      U5      nUR                  U R                  U R
                  U R                  /5      u  pEn[        U R                  XEUS9$ )a+  Returns a new rotated UCS, with the same origin as the source UCS.
The rotation vector is located in the origin and has :ref:`WCS`
coordinates e.g. (0, 0, 1) is the WCS z-axis as rotation vector.

Args:
    axis: arbitrary rotation axis as vector in :ref:`WCS`
    angle: rotation angle in radians

rr   r;   rA   rE   )	r   axis_rotater	   r   r;   rA   rE   r   rr   )r2   axisr   tr;   rA   rE   s          r!   rotate
UCS.rotate  sT       dU3))477DGGTWW*EF
$++";;r#   c                    [         R                  " U R                  U5      nUR                  U R                  U R
                  /5      u  p4[        U R                  U R                  X4S9$ )zlReturns a new rotated UCS, rotation axis is the local x-axis.

Args:
     angle: rotation angle in radians

r   )r   r   r;   r   rA   rE   r   rr   )r2   r   r   rA   rE   s        r!   rotate_local_xUCS.rotate_local_x!  sP       %0%%tww&89$++$''b@@r#   c                    [         R                  " U R                  U5      nUR                  U R                  U R
                  /5      u  p4[        U R                  X0R                  US9$ )zlReturns a new rotated UCS, rotation axis is the local y-axis.

Args:
     angle: rotation angle in radians

r   )r   r   rA   r   r;   rE   r   rr   )r2   r   r   r;   rE   s        r!   rotate_local_yUCS.rotate_local_y,  sP       %0%%tww&89$++"R@@r#   c                    [         R                  " U R                  U5      nUR                  U R                  U R
                  /5      u  p4[        U R                  X4U R                  S9$ )zlReturns a new rotated UCS, rotation axis is the local z-axis.

Args:
     angle: rotation angle in radians

r   )r   r   rE   r   r;   rA   r   rr   )r2   r   r   r;   rA   s        r!   rotate_local_zUCS.rotate_local_z7  sP       %0%%tww&89$++"@@r#   c                B    U =R                   [        U5      -  sl         U $ )z\Shifts current UCS by `delta` vector and returns `self`.

Args:
    delta: shifting vector

)rr   r	   )r2   deltas     r!   shift	UCS.shiftB  s     	tE{"r#   c                &    [        U5      U l        U $ )zgPlace current UCS at new origin `location` and returns `self`.

Args:
    location: new origin in WCS

)r	   rr   )r2   locations     r!   moveto
UCS.movetoL  s     8nr#   c                0    U =R                   U-  sl         U $ )zGeneral inplace transformation interface, returns `self` (floating
interface).

Args:
     m: 4x4 transformation matrix (:class:`ezdxf.math.Matrix44`)

)r1   )r2   ms     r!   r*   UCS.transformV  s     	qr#   c                .    U R                   R                  $ )z0Returns ``True`` if cartesian coordinate system.)r1   is_cartesianr<   s    r!   r   UCS.is_cartesiana  s     {{'''r#   c                f    [        U5      nUR                  [        U5      U -
  5      n[        XUS9$ )aK  Returns a new :class:`UCS` defined by the origin, the x-axis vector
and an arbitrary point in the xy-plane.

Args:
    origin: UCS origin as (x, y, z) tuple in :ref:`WCS`
    axis: x-axis vector as (x, y, z) tuple in :ref:`WCS`
    point: arbitrary point unlike the origin in the xy-plane as
        (x, y, z) tuple in :ref:`WCS`

rr   r;   rE   r	   r/   r   )rr   r   r    x_axisz_axiss        r!   from_x_axis_and_point_in_xyUCS.from_x_axis_and_point_in_xyf  1     dd5kF23&77r#   c                j    [        U5      n[        U5      U -
  nUR                  U5      n[        XUS9$ )aK  Returns a new :class:`UCS` defined by the origin, the x-axis vector
and an arbitrary point in the xz-plane.

Args:
    origin: UCS origin as (x, y, z) tuple in :ref:`WCS`
    axis: x-axis vector as (x, y, z) tuple in :ref:`WCS`
    point: arbitrary point unlike the origin in the xz-plane as
        (x, y, z) tuple in :ref:`WCS`

rr   r;   rA   r   )rr   r   r    r   	xz_vectory_axiss         r!   from_x_axis_and_point_in_xzUCS.from_x_axis_and_point_in_xzx  6     dK&(	(&77r#   c                j    [        U5      n[        U5      U -
  nUR                  U5      n[        XUS9$ )aK  Returns a new :class:`UCS` defined by the origin, the y-axis vector
and an arbitrary point in the xy-plane.

Args:
    origin: UCS origin as (x, y, z) tuple in :ref:`WCS`
    axis: y-axis vector as (x, y, z) tuple in :ref:`WCS`
    point: arbitrary point unlike the origin in the xy-plane as
        (x, y, z) tuple in :ref:`WCS`

rr   rA   rE   r   )rr   r   r    r   	xy_vectorr   s         r!   from_y_axis_and_point_in_xyUCS.from_y_axis_and_point_in_xy  r   r#   c                j    [        U5      n[        U5      U -
  nUR                  U5      n[        XUS9$ )aK  Returns a new :class:`UCS` defined by the origin, the y-axis vector
and an arbitrary point in the yz-plane.

Args:
    origin: UCS origin as (x, y, z) tuple in :ref:`WCS`
    axis: y-axis vector as (x, y, z) tuple in :ref:`WCS`
    point: arbitrary point unlike the origin in the yz-plane as
        (x, y, z) tuple in :ref:`WCS`

r   r   )rr   r   r    r   	yz_vectorr   s         r!   from_y_axis_and_point_in_yzUCS.from_y_axis_and_point_in_yz  r   r#   c                f    [        U5      nUR                  [        U5      U -
  5      n[        XUS9$ )aK  Returns a new :class:`UCS` defined by the origin, the z-axis vector
and an arbitrary point in the xz-plane.

Args:
    origin: UCS origin as (x, y, z) tuple in :ref:`WCS`
    axis: z-axis vector as (x, y, z) tuple in :ref:`WCS`
    point: arbitrary point unlike the origin in the xz-plane as
        (x, y, z) tuple in :ref:`WCS`

r   r   )rr   r   r    r   r   s        r!   from_z_axis_and_point_in_xzUCS.from_z_axis_and_point_in_xz  r   r#   c                j    [        U5      n[        U5      U -
  nUR                  U5      n[        XUS9$ )aK  Returns a new :class:`UCS` defined by the origin, the z-axis vector
and an arbitrary point in the yz-plane.

Args:
    origin: UCS origin as (x, y, z) tuple in :ref:`WCS`
    axis: z-axis vector as (x, y, z) tuple in :ref:`WCS`
    point: arbitrary point unlike the origin in the yz-plane as
        (x, y, z) tuple in :ref:`WCS`

r   r   )rr   r   r    r   r   r   s         r!   from_z_axis_and_point_in_yzUCS.from_z_axis_and_point_in_yz  r   r#   r   r   r   c           
         [        UU R                  U R                  [        U-  5      U R                  [        U-  5      U R                  [
        U-  5      4US9  g)r[   r]   N)r"   rr   rU   r   r   r   r^   s       r!   r"   UCS.render_axis  sP     	++FVO,FVO,FVO,
 		
r#   r   )r\   NNN)rr   r
   r;   Optional[UVec]rA   r   rE   r   rb   )r   r
   rc   rf   )rc   r   r    r	   rc   r	   r   zIterable[Vec3]rc   rd   )r   r	   rc   r	   r   re   rc   re   )r   r	   rc   r	   )r   r
   r   re   rc   r   )r   re   rc   r   )r   r
   rc   r   )r   r
   rc   r   )r   r   rc   r   )rc   bool)rr   r
   r   r
   r    r
   rc   r   )r   r   r_   re   r   r   )*rg   rh   ri   rj   rk   r7   rl   r;   rA   rE   rr   setterr   rU   rX   r   rJ   rO   r   r   r   r   r   r   r   r   r   r   r   r   r*   r   staticmethodr   r   r   r   r   r   r   r"   rm   rn   r#   r!   r   r   t   s   * !!!!JJ J 	J
 J<       " " ]] ;,676":-+	QG<	A	A	A	 ( ( 88 8)-8	8 8" 88 8)-8	8 8$ 88 8)-8	8 8$ 88 8)-8	8 8$ 88 8)-8	8 8" 88 8)-8	8 8* !Ql	

 
 	
 
r#   r   c                  |   ^  \ rS rSrSrU 4S jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSrU =r$ )r   i  z5UCS is equal to the WCS and OCS (extrusion = 0, 0, 1)c                "   > [         TU ]  5         g r'   )superr7   )r2   	__class__s    r!   r7   PassTroughUCS.__init__  s    r#   c                    U$ r'   rn   rT   s     r!   rU   PassTroughUCS.to_wcs      r#   c                    [        U5      $ r'   iterr   s     r!   rX   PassTroughUCS.points_to_wcs      F|r#   c                    U$ r'   rn   rT   s     r!   r   PassTroughUCS.to_ocs  r   r#   c                    [        U5      $ r'   r  r   s     r!   r   PassTroughUCS.points_to_ocs  r  r#   c                    U$ r'   rn   r   s     r!   r   PassTroughUCS.to_ocs_angle_deg  r   r#   c                    U$ r'   rn   r   s     r!   r   PassTroughUCS.to_ocs_angle_rad  r   r#   c                    U$ r'   rn   rT   s     r!   rJ   PassTroughUCS.from_wcs  r   r#   c                    [        U5      $ r'   r  r   s     r!   rO   PassTroughUCS.points_from_wcs  r  r#   rn   r   r   r   )rg   rh   ri   rj   rk   r7   rU   rX   r   r   r   r   rJ   rO   rm   __classcell__)r   s   @r!   r   r     s8    ? r#   r   N)
r   r   r   r
   r   zSequence[UVec]r   r   rc   rf   )
__future__r   typingr   r   r   r   r   
ezdxf.mathr	   r
   r   r   r   r   ezdxf.colorsr   ezdxf.layoutsr   __all__r"   r-   r   r   r   rn   r#   r!   <module>r     s    # H H C C (
) aA,	CCC C 	C
 
C 
V
 V
rr
 r
jC r#   