
    P/Ph                         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 ej        d          d             Zd Zd Zd ZdS )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.
    N   r   )r   r   r   r   nparray)xminxmaxyminymaxzminzmax	pb_aspectdxdydzaxayazs                [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mpl_toolkits/mplot3d/proj3d.pyworld_transformationr   
   s     
B	B	B
B
b
b
b8adqQb1AbDQb1q!B$b11113 4 4 4    c                    | t           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    RY^^A&&&JBB
uA
uA	"&q//1
A
	
2b12b2a42b2a48	
2b2a42b12b2a48	
2b2a42b2a42b157 	8 	8A
 Hr   c                 t   | |z
  }|t           j                            |          z  }t          j        ||          }|t           j                            |          z  }t          j        ||          }|dk    r;t	          ||           }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 qyy&q4%00F5!F5!a7Nr   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Brr2A2vJBrr2vJ
r2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   s~    A	A	u%A
F5L6%<(A(Q!aO!aO!aO+OO- . .K r   c           	      b    | |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   {   sW    
5.A
5.A(MMM)MM)MMAqM+ , ,K r   c                 x   t          j        || j                  }|d         }|d         |z  |d         |z  |d         |z  }}}t           j                            | d                   r,t           j                            || d         j                  }t           j                            | d                   r,t           j                            || d         j                  }t           j                            | d                   r,t           j                            || d         j                  }|||fS )Nr5   r   r   r   )mask)r   r+   datamaisMAr   rI   )vecr:   vecwr/   txstystzss          r   _proj_transform_vecrR      s    6!SXDQAGAItAwqy$q'!)cC	uzz#a& 1ekk#CFKk00	uzz#a& 1ekk#CFKk00	uzz#a& 1ekk#CFKk00S=r   c                 L   t          j        || j                  }|d         }|d         |z  |d         |z  |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                            | d                   r|| d         j	         z  }t           j                            | d                   r|| d         j	         z  }t           j                            | d                   r|| d         j	         z  }t           j        
                    ||           }t           j        
                    ||           }t           j        
                    ||           }||||fS )Nr5   r   r   r   )dtyper6   )r   r+   rJ   isinfonesshapeboolrK   rL   rI   masked_array)	rM   r:   r@   rN   r/   rO   rP   rQ   tiss	            r   _proj_transform_vec_clipr[      sy   6!SXDQAGaKa1d1gkcC	x Ogcit,,,SySAX&")4qASAXN	uzz#a& !SV[L 	uzz#a& !SV[L 	uzz#a& !SV[L 
%

S3$
'
'C
%

S3$
'
'C
%

S3$
'
'CS#r   c                 ^   t          | ||          }t          j        ||          }|j        dk    r|                    d          }t          |j        d                   D ]6}|d         |         dk    r"|dd|f         |d         |         z  |dd|f<   7|d         |d         |d         fS )zO
    Transform the points by the inverse of the projection matrix, *invM*.
    )r4   )r4   r   r   r5   r   Nr   )_vec_pad_onesr   r+   rW   reshaperange)xsyszsinvMrM   vecris          r   inv_transformrf      s     B
#
#C6$DzT||F##4:a=!! 1 171:??aaadd1gaj0DAJ7DGT!W$$r   c                 z   t           j                            |           s>t           j                            |          st           j                            |          r5t           j                            | ||t          j        |           g          S t          j        | ||t          j        |           g          S N)r   rK   rL   r   	ones_like)r`   ra   rb   s      r   r]   r]      s    	uzz"~~ 8B 825::b>> 8u{{BBR(8(89:::xRR\"%5%56777r   c                 D    t          | ||          }t          ||          S )z<
    Transform the points by the projection matrix *M*.
    )r]   rR   )r`   ra   rb   r:   rM   s        r   proj_transformrk      s%     B
#
#CsA&&&r   z3.10c                 >    t          | |||t          j                  S )N)r@   )_proj_transform_clipr   inf)r`   ra   rb   r:   s       r   proj_transform_clipro      s    BABFCCCCr   c                 F    t          | ||          }t          |||          S )zy
    Transform the points by the projection matrix
    and return the clipping result
    returns txs, tys, tzs, tis
    )r]   r[   )r`   ra   rb   r:   r@   rM   s         r   rm   rm      s'     B
#
#C#CL999r   c                 F    t          j        t          | |                    S rh   )r   column_stack_proj_trans_points)pointsr:   s     r   _proj_pointsru      s    ?-fa88999r   c                     t          j        |           } | d d df         | d d df         | d d df         }}}t          ||||          S )Nr   r   r   )r   
asanyarrayrk   )rt   r:   r`   ra   rb   s        r   rs   rs      sV    ]6""F1vaaad|VAAAqD\BB"b"a(((r   rh   )__doc__numpyr   
matplotlibr   r   r(   r2   r;   rE   rG   rR   r[   rf   r]   rk   
deprecatedro   rm   ru   rs    r   r   <module>r}      sA             
 044 4 4 4,  "$ $ $N  .	 	 	  
 
 
  *% % %8 8 8' ' ' D D D: : :: : :) ) ) ) )r   