
    DVf                        d Z ddlZddlmZ 	 ddZ ej                  d      d        Zd Zd Z	d	 Z
 ej                  d      d
        Z ej                  d      d        Zd Z ej                  d      d        Zd Zd Zd Zd Zd Zd Z  ej                  dddd      e      Zd Z ej                  d      d        Zd Z ej                  d      d        Zd Z ej                  d      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                d/var/www/html/software/conda/envs/catlas/lib/python3.12/site-packages/mpl_toolkits/mplot3d/proj3d.pyworld_transformationr   
   s     
B	B	B
B
b
b
b88adA!b1AbD!b1A!B$b1*, - -    z3.8c                     t        | |      S )K
    Produce a rotation matrix for an angle in radians about a vector.
    )_rotation_about_vector)vangles     r   rotation_about_vectorr       s    
 "!U++r   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 )r      )r   linalgnormsincosr	   )	r   r   vxvyvzsctRs	            r   r   r   (   s    RYY^^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 	8A
 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_axesr6   9   s    0 
QA	"))..
A
AA	"))..
A
AA qy&q4%0FF5!FF5!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/   )r4   r   r3   r0   MrMtMs          r   _view_transformation_uvwr?   `   s`     
B	BQBrr2A2vJBrr2vJ
r2AHr   c                 F    t        | |||      \  }}}t        ||||       }|S )az  
    Return the view transformation matrix.

    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.
    )r6   r?   )r0   r,   r1   r2   r4   r   r3   r>   s           r   view_transformationrA   w   s/      Aq$'GAq! Aq!,AHr   c                     t        | ||      S N)_persp_transformation)zfrontzbackfocal_lengths      r   persp_transformationrH      s     ==r   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   r:   r   r   )rE   rF   rG   eabr*   proj_matrixs           r   rD   rD      sw    A	A	u%A
F5L6%<(A((Q!aO!aO!aO+- .K r   c                     t        | |      S rC   )_ortho_transformation)rE   rF   s     r   ortho_transformationrQ      s     //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   rJ   r   r   r   )rE   rF   rL   rM   rN   s        r   rP   rP      sH    
5.A
5.A((M))AqM+ ,K r   c                 r    t        j                  ||       }|d   }|d   |z  |d   |z  |d   |z  }}}|||fS Nr9   r   r   r!   )r   r/   )vecr>   vecwr3   txstystzss          r   _proj_transform_vecrZ      sK    66!S>DQAGAItAwqy$q'!)cCS=r   c                     t        j                  ||       }|d   }|d   |z  |d   |z  |d   |z  }}}d|d   k  |d   dk  z  d|d   k  z  |d   dk  z  }t        j                  |      r|d   dk  }||||fS rT   )r   r/   any)rU   r>   rV   r3   rW   rX   rY   tiss           r   _proj_transform_vec_clipr^      s    66!S>DQAGaKa1d1gkcCQ<DGqL
)Q$q'\
:d1gl
KC	vvc{1gk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*.
    )r8   )r8   r   r   r9   r   Nr!   )_vec_pad_onesr   r/   shapereshaperange)xsyszsinvMrU   vecris          r   inv_transformrj      s     B
#C66$DzzT||F#4::a=! 171:?add1gaj0DAJ1 7DGT!W$$r   c                 Z    t        j                  | ||t        j                  |       g      S rC   )r   r	   	ones_like)rd   re   rf   s      r   r`   r`      s#    88RRb!1233r   c                 4    t        | ||      }t        ||      S )z<
    Transform the points by the projection matrix *M*.
    )r`   rZ   rd   re   rf   r>   rU   s        r   proj_transformro      s     B
#CsA&&r   function	transformro   )obj_typenamealternativec                 4    t        | ||      }t        ||      S )zy
    Transform the points by the projection matrix
    and return the clipping result
    returns txs, tys, tzs, tis
    )r`   r^   rn   s        r   proj_transform_cliprv      s     B
#C#C++r   c                     t        | |      S rC   )_proj_pointspointsr>   s     r   proj_pointsr{      s    ""r   c                 @    t        j                  t        | |            S rC   )r   column_stack_proj_trans_pointsry   s     r   rx   rx      s    ??-fa899r   c                     t        | |      S rC   )r~   ry   s     r   proj_trans_pointsr      s    fa((r   c                 6    t        |  \  }}}t        ||||      S rC   )zipro   )rz   r>   rd   re   rf   s        r   r~   r~      s"    fJBB"b"a((r   c                     t        j                  |      t        j                  |      }}t        j                  g dd|| dgd||dgg dg      }t        j                  ||       S )N)r   r   r   r   r   r   )r   r%   r$   r	   r/   )r1   alphacosasinaM1s        r   rot_xr      s_    u$D	<tdUA&tT1%! 
"B 66"a=r   rC   )__doc__numpyr   
matplotlibr   r   
deprecatedr   r   r6   r?   rA   rH   rD   rQ   rP   rZ   r^   rj   r`   ro   rq   rv   r{   rx   r   r~   r    r   r   <module>r      s]    
 04-, , ,"$N.  ( > >	 0 0%4'"ODOO	J[ ""02	
, # #: ) ))
  r   