Ë
    íÍ:jN  ã                   ó°   — d Z ddlZddlmZ 	 dd„Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z ej$                  d«      d„ «       Zd„ Zd„ Zd„ Zy)z,
Various transforms used for by the 3D code
é    N)Ú_apic           	      óÆ   — || z
  }||z
  }||z
  }	|�|\  }
}}||
z  }||z  }|	|z  }	t        j                  d|z  dd|  |z  gdd|z  d| |z  gddd|	z  | |	z  gg d¢g«      S )zŸ
    Produce a matrix that scales homogeneous coords in the specified ranges
    to [0, 1], or [0, pb_aspect[i]] if the plotbox aspect ratio is specified.
    é   r   )r   r   r   r   ©ÚnpÚarray)ÚxminÚxmaxÚyminÚymaxÚzminÚzmaxÚ	pb_aspectÚdxÚdyÚdzÚaxÚayÚazs                úp/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/mpl_toolkits/mplot3d/proj3d.pyÚworld_transformationr   
   s¥   € ð 
�‰€BØ	�‰€BØ	�‰€BØÐØ‰
ˆˆB�Ø
ˆb‰ˆØ
ˆb‰ˆØ
ˆb‰ˆä�8‰8�a˜‘d˜q Q¨¨¨b©Ð1Ø˜A˜b™D Q¨¨¨b©Ð1Ø˜q ! B¡$¨¨¨b©Ð1Ú1ð3ó 4ð 4ó    c                 óê  — | t         j                  j                  | «      z  \  }}}t        j                  |«      }t        j                  |«      }dt        j                  |dz  «      dz  z  }t        j
                  ||z  |z  |z   ||z  |z  ||z  z
  ||z  |z  ||z  z   g||z  |z  ||z  z   ||z  |z  |z   ||z  |z  ||z  z
  g||z  |z  ||z  z
  ||z  |z  ||z  z   ||z  |z  |z   gg«      }|S )zK
    Produce a rotation matrix for an angle in radians about a vector.
    é   )r   ÚlinalgÚnormÚsinÚcosr   )	ÚvÚangleÚvxÚvyÚvzÚsÚcÚtÚRs	            r   Ú_rotation_about_vectorr(       s  € ð ”R—Y‘Y—^‘^ AÓ&Ñ&�J€BˆˆBÜ
�‰ˆu‹€AÜ
�‰ˆu‹€AØ	Œ"�&‰&��q‘‹/˜1Ñ
Ñ€Aä
�‰Ø	
ˆ2‰ˆb‰�1‰˜˜2™˜b™ 2 a¡4™¨¨2©¨b©°2°a±4©Ð8Ø	
ˆ2‰ˆb‰�2�a‘4‰˜˜2™˜b™ 1™¨¨2©¨b©°2°a±4©Ð8Ø	
ˆ2‰ˆb‰�2�a‘4‰˜˜2™˜b™ 2 a¡4™¨¨2©¨b©°1©Ð5ð7ó 	8€Að
 €Hr   c                 ór  — | |z
  }|t         j                  j                  |«      z  }t        j                  ||«      }|t         j                  j                  |«      z  }t        j                  ||«      }|dk7  r9t	        || «      }t        j
                  ||«      }t        j
                  ||«      }|||fS )aŸ  
    Get the unit viewing axes in data coordinates.

    Parameters
    ----------
    E : 3-element numpy array
        The coordinates of the eye/camera.
    R : 3-element numpy array
        The coordinates of the center of the view box.
    V : 3-element numpy array
        Unit vector in the direction of the vertical axis.
    roll : float
        The roll angle in radians.

    Returns
    -------
    u : 3-element numpy array
        Unit vector pointing towards the right of the screen.
    v : 3-element numpy array
        Unit vector pointing towards the top of the screen.
    w : 3-element numpy array
        Unit vector pointing out of the screen.
    r   )r   r   r   Úcrossr(   Údot)ÚEr'   ÚVÚrollÚwÚur   ÚRrolls           r   Ú
_view_axesr2   1   s›   € ð0 
ˆQ‰€AØ	Œ"�)‰)�.‰.˜Ó
Ñ€AÜ
�‰��A‹€AØ	Œ"�)‰)�.‰.˜Ó
Ñ€AÜ
�‰��A‹€Að ˆq‚yä& q¨4¨%Ó0ˆÜ�F‰F�5˜!ÓˆÜ�F‰F�5˜!ÓˆØˆa�ˆ7€Nr   c                 ó¶   — t        j                  d«      }t        j                  d«      }| ||g|dd…dd…f<   | |dd…df<   t        j                  ||«      }|S )aœ  
    Return the view transformation matrix.

    Parameters
    ----------
    u : 3-element numpy array
        Unit vector pointing towards the right of the screen.
    v : 3-element numpy array
        Unit vector pointing towards the top of the screen.
    w : 3-element numpy array
        Unit vector pointing out of the screen.
    E : 3-element numpy array
        The coordinates of the eye/camera.
    é   Né   éÿÿÿÿ)r   Úeyer+   )r0   r   r/   r,   ÚMrÚMtÚMs          r   Ú_view_transformation_uvwr;   X   s`   € ô 
�‰�‹€BÜ	�‰�‹€BØ�Q˜�€B€rˆ€rˆ2ˆAˆ2€v�JØ�€B€rˆ€rˆ2€v�JÜ
�‰ˆr�2‹€AØ€Hr   c                 ó”   — |}d}| |z   | |z
  z  }d| |z  z  | |z
  z  }t        j                  |dddgd||z  ddgdd||gg d¢g«      }|S )Nr   éþÿÿÿr   )r   r   r6   r   r   )ÚzfrontÚzbackÚfocal_lengthÚeÚaÚbr%   Úproj_matrixs           r   Ú_persp_transformationrE   o   sw   € Ø€AØ	€AØ	�‰˜˜u™Ñ%€AØ
ˆF�5‰LÑ˜6 %™<Ñ(€AÜ—(‘(˜Q ! a¨˜OØ  !¡ a¨˜OØ ! a¨˜OÚ+ð-ó .€Kð Ðr   c           	      ód   — | |z    }| |z
   }t        j                  g d¢g d¢g d¢dd||gg«      }|S )N)r   r   r   r   )r   r   r   r   )r   r   r=   r   r   r   )r>   r?   rB   rC   rD   s        r   Ú_ortho_transformationrG   {   sH   € à
�5‰.Ð€AØ
�5‰.Ð€AÜ—(‘(šMÚ)Ú)Ø  A q˜Mð+ó ,€Kð Ðr   c                 ód  — d„ } || |j                   «      } |||j                  «      } |||j                  «      }| ||fD �cg c]!  }t        j                  j                  |«      ‘Œ# }	}t        d„ |	D «       «      rªt        j                  j                  t        j                  j                  |	d   |	d   «      |	d   «      }
t        j                  j                  ||
¬«      }t        j                  j                  ||
¬«      }t        j                  j                  ||
¬«      }|||fS c c}w )zÁ
    Apply axis scale transforms to 3D coordinates.

    Transforms data coordinates to transformed coordinates (applying log,
    symlog, etc.) for 3D projection. Preserves masked arrays.
    c                 óö   — t        j                  | «      } t         j                  j                  | «      j	                  «       }|j                  «       j                  |«      j                  | j                  «      S ©N)	r   Ú
asanyarrayÚmaÚgetdataÚravelÚget_transformÚ	transformÚreshapeÚshape)ÚcoordÚaxisÚdatas      r   Útransform_coordz0_apply_scale_transforms.<locals>.transform_coord�   sT   € Ü—‘˜eÓ$ˆÜ�u‰u�}‰}˜UÓ#×)Ñ)Ó+ˆØ×!Ñ!Ó#×-Ñ-¨dÓ3×;Ñ;¸E¿K¹KÓHÐHr   c              3   óT   K  — | ]   }|t         j                  j                  u–— Œ" y ­wrJ   )r   rL   Únomask)Ú.0Úms     r   ú	<genexpr>z*_apply_scale_transforms.<locals>.<genexpr>˜   s   è ø€ Ò
0 Qˆ1”B—E‘E—L‘LÔ Ñ
0ùs   ‚&(r   r   r   ©Úmask)	ÚxaxisÚyaxisÚzaxisr   rL   ÚgetmaskÚanyÚmask_orr   )ÚxsÚysÚzsÚaxesrV   Ú	xs_scaledÚ	ys_scaledÚ	zs_scaledrB   ÚmasksÚcombineds              r   Ú_apply_scale_transformsrm   †   só   € òIñ
    D§J¡JÓ/€IÙ  D§J¡JÓ/€IÙ  D§J¡JÓ/€Ið )+¨B° |Ö4 !ŒR�U‰U�]‰]˜1ÕÐ4€EÐ4Ü
Ñ
0¨%Ô
0Ô0Ü—5‘5—=‘=¤§¡§¡¨u°Q©x¸¸q¹Ó!BÀEÈ!ÁHÓMˆÜ—E‘E—K‘K 	°�KÓ9ˆ	Ü—E‘E—K‘K 	°�KÓ9ˆ	Ü—E‘E—K‘K 	°�KÓ9ˆ	à�i Ð*Ð*ùò 5s   Á&D-c                 ó  — t        j                  || j                  «      }|dd |d   z  }t         j                  j	                  | «      r+t         j                  j                  || j                  ¬«      }|d   |d   |d   fS )Nr   r5   r\   r   r   )r   r+   rU   rL   ÚisMAr   r]   )Úvecr:   ÚvecwÚtss       r   Ú_proj_transform_vecrs   ¡   sl   € Ü�6‰6�!�S—X‘XÓ€DØ	ˆa�ˆ�4˜‘7Ñ	€BÜ	‡u�u‡z�z�#„Ü�U‰U�[‰[˜ #§(¡(ˆ[Ó+ˆØˆa‰5�"�Q‘%˜˜A™ÐÐr   c                 óJ  — | j                   }t        | d   | d   | d   |«      \  }}}t        |j                  «       |j                  «       |j                  «       «      }t	        j
                  |j                  |«      }|dd |d   z  }|j                  j                  |«      S )zâ
    Apply scale transforms and project vectors.

    Parameters
    ----------
    vecs : ... x 3 np.ndarray
        Input vectors.
    axes : Axes3D
        The 3D axes (used for scale transforms and projection matrix).
    ).r   ).r   ).r   Nr5   )	rR   rm   Ú_vec_pad_onesrN   r   r+   r:   ÚTrQ   )	Úvecsrg   Úresult_shaperd   re   rf   rp   ÚproductÚtvecss	            r   Ú_scale_proj_transform_vectorsr{   ©   s�   € ð —:‘:€LÜ(ØˆV‰�d˜6‘l D¨¡L°$ó8�J€BˆˆBä
˜Ÿ™›
 B§H¡H£J°·±³
Ó
;€CÜ�f‰f�T—V‘V˜SÓ!€GØ�B�QˆK˜' !™*Ñ$€EØ�7‰7�?‰?˜<Ó(Ð(r   c                 ó   — t        j                  || j                  «      }|dd |d   z  \  }}}t        j                  |«      r&t        j                  |j
                  t        ¬«      }nd|k  |dk  z  d|k  z  |dk  z  |dk  z  }t         j                  j                  | d   «      r|| d   j                   z  }t         j                  j                  | d   «      r|| d   j                   z  }t         j                  j                  | d   «      r|| d   j                   z  }t         j                  j                  || «      }t         j                  j                  || «      }t         j                  j                  || «      }||||fS )Nr   r5   )Údtyper6   r   r   )r   r+   rU   ÚisinfÚonesrR   ÚboolrL   ro   r]   Úmasked_array)rp   r:   r@   rq   ÚtxsÚtysÚtzsÚtiss           r   Ú_proj_transform_vec_clipr†   ½   sL  € Ü�6‰6�!�S—X‘XÓ€DØ˜˜1�I  Q¡Ñ'�M€CˆˆcÜ	‡x�x�ÔÜ�g‰g�c—i‘i¤tÔ,‰à�S‰y˜S A™XÑ&¨"°©)Ñ4¸¸q¹ÑAÀSÈAÁXÑNˆÜ	‡u�u‡z�z�#�a‘&ÔØ�S˜‘V—[‘[�LÑ ˆÜ	‡u�u‡z�z�#�a‘&ÔØ�S˜‘V—[‘[�LÑ ˆÜ	‡u�u‡z�z�#�a‘&ÔØ�S˜‘V—[‘[�LÑ ˆä
�%‰%×
Ñ
˜S 3 $Ó
'€CÜ
�%‰%×
Ñ
˜S 3 $Ó
'€CÜ
�%‰%×
Ñ
˜S 3 $Ó
'€CØ��S˜#ÐÐr   c                 ó(  — t        | ||«      }t        j                  ||«      }|j                  dk(  r|j	                  d«      }t        |j                  d   «      D ]'  }|d   |   dk7  sŒ|dd…|f   |d   |   z  |dd…|f<   Œ) |d   |d   |d   fS )zO
    Transform the points by the inverse of the projection matrix, *invM*.
    )r4   )r4   r   r   r5   r   Nr   )ru   r   r+   rR   rQ   Úrange)rd   re   rf   ÚinvMrp   ÚvecrÚis          r   Úinv_transformrŒ   Ñ   s¤   € ô ˜˜B Ó
#€CÜ�6‰6�$˜Ó€DØ‡z�z�TÒØ�|‰|˜FÓ#ˆÜ�4—:‘:˜a‘=Ó!ò 1ˆØ�‰7�1‰:˜‹?Øša ˜d™ d¨1¡g¨a¡jÑ0ˆD’�A�ŠJð1ð �‰7�D˜‘G˜T !™WÐ$Ð$r   c                 ó€  — t         j                  j                  | «      s>t         j                  j                  |«      st         j                  j                  |«      r6t         j                  j                  | ||t        j                  | «      g«      S t        j                  | ||t        j                  | «      g«      S rJ   )r   rL   ro   r   Ú	ones_like)rd   re   rf   s      r   ru   ru   ß   ss   € Ü	‡u�u‡z�z�"„~œŸ™Ÿ™ Bœ¬2¯5©5¯:©:°b¬>Ü�u‰u�{‰{˜B  B¬¯©°RÓ(8Ð9Ó:Ð:ä�x‰x˜˜R ¤R§\¡\°"Ó%5Ð6Ó7Ð7r   c                 ó4   — t        | ||«      }t        ||«      S )z<
    Transform the points by the projection matrix *M*.
    )ru   rs   ©rd   re   rf   r:   rp   s        r   Úproj_transformr‘   æ   s   € ô ˜˜B Ó
#€CÜ˜s AÓ&Ð&r   z3.10c                 óT   — t        | ||«      }t        ||t        j                  ¬«      S )N)r@   )ru   r†   r   Úinfr�   s        r   Úproj_transform_clipr”   î   s#   € ä
˜˜B Ó
#€CÜ# C¨¼¿¹Ô@Ð@r   c                 ó‚   — t        | |||«      \  } }}t        | ||«      }t        ||j                  |j                  «      S )zg
    Apply scale transforms, project, and return clipping result.

    Returns txs, tys, tzs, tis.
    )rm   ru   r†   r:   Ú_focal_length)rd   re   rf   rg   rp   s        r   Ú_scale_proj_transform_clipr—   ô   sA   € ô )¨¨R°°TÓ:�J€BˆˆBÜ
˜˜B Ó
#€CÜ# C¨¯©°×1CÑ1CÓDÐDr   c                 ó~   — t        j                  | «      } | d d …df   | d d …df   | d d …df   }}}t        ||||«      S )Nr   r   r   )r   rK   r‘   )Úpointsr:   rd   re   rf   s        r   Ú_proj_trans_pointsrš   ÿ   sF   € Ü�]‰]˜6Ó"€FØš˜1˜‘˜v¢a¨ d™|¨V²A°q°D©\ˆBˆ€BÜ˜"˜b " aÓ(Ð(r   c                 óV   — t        | |||«      \  } }}t        | |||j                  «      S )z™
    Apply scale transforms and project.

    Combines `_apply_scale_transforms` and `proj_transform` into a single
    call. Returns txs, tys, tzs.
    )rm   r‘   r:   )rd   re   rf   rg   s       r   Ú_scale_proj_transformrœ     s/   € ô )¨¨R°°TÓ:�J€BˆˆBÜ˜"˜b " d§f¡fÓ-Ð-r   rJ   )Ú__doc__Únumpyr   Ú
matplotlibr   r   r(   r2   r;   rE   rG   rm   rs   r{   r†   rŒ   ru   r‘   Ú
deprecatedr”   r—   rš   rœ   © r   r   ú<module>r¢      sŠ   ðñó å ð
 04ó4ò,ò"$òNò.	òò+ò6ò)ò(ò(%ò8ò'ð €‡��ÓñAó ðAò
Eò)ó.r   