
    
3jN                         S r SSKrSSKJr   SS jrS rS rS rS r	S	 r
S
 rS rS rS rS rS rS r\R$                  " S5      S 5       rS rS rS rg)z,
Various transforms used for by the 3D code
    N)_apic           	          X-
  nX2-
  nXT-
  n	Ub  Uu  pnXz-  nX-  nX-  n	[         R                  " SU-  SSU * U-  /SSU-  SU* U-  /SSSU	-  U* U	-  // SQ/5      $ )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                U/home/wildlama/miniconda3/lib/python3.13/site-packages/mpl_toolkits/mplot3d/proj3d.pyworld_transformationr   
   s     
B	B	B



88adqQb1AbDQb1q!B$b113 4 4    c                    U [         R                  R                  U 5      -  u  p#n[         R                  " U5      n[         R                  " U5      nS[         R                  " US-  5      S-  -  n[         R
                  " Xr-  U-  U-   Xr-  U-  XE-  -
  Xr-  U-  X5-  -   /Xs-  U-  XE-  -   Xs-  U-  U-   Xs-  U-  X%-  -
  /Xt-  U-  X5-  -
  Xt-  U-  X%-  -   Xt-  U-  U-   //5      nU$ )zC
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     RYY^^A&&JBB
uA
uA	"&&q/1
A
	
b1b24b248	
b24b1b248	
b24b24b157 	8A
 Hr   c                 n   X-
  nU[         R                  R                  U5      -  n[         R                  " X$5      nU[         R                  R                  U5      -  n[         R                  " XE5      nUS:w  a8  [	        XC* 5      n[         R
                  " Xu5      n[         R
                  " Xv5      nXVU4$ )aO  
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 
A	"))..
A
A	"))..
A
A qy&q%0FF5FF57Nr   c                     [         R                  " S5      n[         R                  " S5      nXU/USS2SS24'   U* USS2S4'   [         R                  " XE5      nU$ )al  
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Brr2A2vJBrr2vJ
rAHr   c                     UnSnX-   X-
  -  nSX-  -  X-
  -  n[         R                  " USSS/SX4-  SS/SSXV// SQ/5      nU$ )Nr   r   )r   r   r6   r   r   )zfrontzbackfocal_lengtheabr%   proj_matrixs           r   _persp_transformationrE   o   sk    A	A	%A
FL6<(A((Q!aOaO!aO+- .K r   c           	      `    X-   * nX-
  * n[         R                  " / SQ/ SQ/ SQSSX#//5      nU$ )N)r   r   r   r   )r   r   r   r   )r   r   r=   r   r   r   )r>   r?   rB   rC   rD   s        r   _ortho_transformationrG   {   sB    
.A
.A((M))AM+ ,K r   c                 R   S nU" XR                   5      nU" XR                  5      nU" X#R                  5      nXU4 Vs/ s H"  n[        R                  R                  U5      PM$     n	n[        S U	 5       5      (       a  [        R                  R                  [        R                  R                  U	S   U	S   5      U	S   5      n
[        R                  R                  XZS9n[        R                  R                  XjS9n[        R                  R                  XzS9nXVU4$ s  snf )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                     [         R                  " U 5      n [         R                  R                  U 5      R	                  5       nUR                  5       R                  U5      R                  U R                  5      $ N)	r   
asanyarraymagetdataravelget_transform	transformreshapeshape)coordaxisdatas      r   transform_coord0_apply_scale_transforms.<locals>.transform_coord   sT    e$uu}}U#))+!!#--d3;;EKKHHr   c              3   X   #    U  H   o[         R                  R                  Lv   M"     g 7frJ   )r   rL   nomask).0ms     r   	<genexpr>*_apply_scale_transforms.<locals>.<genexpr>   s     
0%QBEELL %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_transformsro      s    I
  JJ/IJJ/IJJ/I )+|4|!RUU]]1|E4

0%
00055==uQxq!BE!HMEEKK	K9	EEKK	K9	EEKK	K9	** 5s    )D$c                 
   [         R                  " XR                  5      nUSS US   -  n[         R                  R	                  U 5      (       a'  [         R                  R                  X0R                  S9nUS   US   US   4$ )Nr   r5   r^   r   r   )r   r+   rU   rL   isMAr   r_   )vecr:   vecwtss       r   _proj_transform_vecru      sj    66!XXD	a47	B	uuzz#UU[[(([+a5"Q%Ar   c                 J   U R                   n[        U S   U S   U S   U5      u  p4n[        UR                  5       UR                  5       UR                  5       5      n[        R
                  " UR                  U5      nUSS US   -  nUR                  R                  U5      $ )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   ro   _vec_pad_onesrN   r   r+   r:   TrQ   )	vecsri   result_shaperf   rg   rh   rr   producttvecss	            r   _scale_proj_transform_vectorsr}      s     ::L(Vd6lDL$8JBB

BHHJ

;CffTVVS!GBQK'!*$E77??<((r   c                 4   [         R                  " XR                  5      nUSS US   -  u  pEn[         R                  " U5      (       a$  [         R                  " UR
                  [        S9nOSU:*  US:*  -  SU:*  -  US:*  -  US:*  -  n[         R                  R                  U S   5      (       a  XpS   R                  ) -  n[         R                  R                  U S   5      (       a  XpS   R                  ) -  n[         R                  R                  U S   5      (       a  XpS   R                  ) -  n[         R                  R                  XG) 5      n[         R                  R                  XW) 5      n[         R                  R                  Xg) 5      nXEXg4$ )Nr   r5   )dtyper6   r   r   )r   r+   rU   isinfonesrR   boolrL   rq   r_   masked_array)rr   r:   r@   rs   txstystzstiss           r   _proj_transform_vec_clipr      sD   66!XXD1IQ'MCc	xxggciit,SySAX&")4qASAXN	uuzz#a&V[[L 	uuzz#a&V[[L 	uuzz#a&V[[L 
%%

S$
'C
%%

S$
'C
%%

S$
'CSr   c                 0   [        XU5      n[        R                  " X45      nUR                  S:X  a  UR	                  S5      n[        UR                  S   5       H*  nUS   U   S:w  d  M  USS2U4   US   U   -  USS2U4'   M,     US   US   US   4$ )zG
Transform the points by the inverse of the projection matrix, *invM*.
)r4   )r4   r   r   r5   r   Nr   )rw   r   r+   rR   rQ   range)rf   rg   rh   invMrr   vecris          r   inv_transformr      s     
#C66$DzzT||F#4::a=!71:?add1gaj0DAJ " 7DGT!W$$r   c                    [         R                  R                  U 5      (       dH  [         R                  R                  U5      (       d$  [         R                  R                  U5      (       a6  [         R                  R                  XU[         R                  " U 5      /5      $ [         R                  " XU[         R                  " U 5      /5      $ rJ   )r   rL   rq   r   	ones_like)rf   rg   rh   s      r   rw   rw      su    	uuzz"~~B255::b>>uu{{BBR(89::xxR\\"%5677r   c                 0    [        XU5      n[        XC5      $ )z4
Transform the points by the projection matrix *M*.
)rw   ru   rf   rg   rh   r:   rr   s        r   proj_transformr      s     
#Cs&&r   z3.10c                 J    [        XU5      n[        XC[        R                  S9$ )N)r@   )rw   r   r   infr   s        r   proj_transform_clipr      s    

#C#C@@r   c                 x    [        XX#5      u  pn[        XU5      n[        XCR                  UR                  5      $ )z[
Apply scale transforms, project, and return clipping result.

Returns txs, tys, tzs, tis.
)ro   rw   r   r:   _focal_length)rf   rg   rh   ri   rr   s        r   _scale_proj_transform_clipr      s7     ):JBB

#C#C1C1CDDr   c                 z    [         R                  " U 5      n U S S 2S4   U S S 2S4   U S S 2S4   pCn[        X#XA5      $ )Nr   r   r   )r   rK   r   )pointsr:   rf   rg   rh   s        r   _proj_trans_pointsr      s@    ]]6"F1vad|VAqD\BB""((r   c                 L    [        XX#5      u  pn[        XX#R                  5      $ )z
Apply scale transforms and project.

Combines `_apply_scale_transforms` and `proj_transform` into a single
call. Returns txs, tys, tzs.
)ro   r   r:   )rf   rg   rh   ri   s       r   _scale_proj_transformr     s%     ):JBB""ff--r   rJ   )__doc__numpyr   
matplotlibr   r   r(   r2   r;   rE   rG   ro   ru   r}   r   r   rw   r   
deprecatedr   r   r   r    r   r   <module>r      s     
 044,"$N.	+6)((%8' A A
E).r   