
    Ng                        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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                W/var/www/html/ai-engine/env/lib/python3.11/site-packages/mpl_toolkits/mplot3d/proj3d.pyworld_transformationr   
   s     
B	B	B
B
b
b
b8a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                            |           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    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_axesr6   9   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/   )r4   r   r3   r0   MrMtMs          r   _view_transformation_uvwr?   `   s`     
B	BQBrr2A2vJBrr2vJ
r2AHr   c                 V    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   s5      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      s~    A	A	u%A
F5L6%<(A(Q!aO!aO!aO+OO- . .K r   c                 "    t          | |          S rC   )_ortho_transformation)rE   rF   s     r   ortho_transformationrQ      s     ///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   rJ   r   r   r   )rE   rF   rL   rM   rN   s        r   rP   rP      sW    
5.A
5.A(MMM)MM)MMAqM+ , ,K r   c                     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    6!S>>DQAGAItAwqy$q'!)cCS=r   c                 0   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    6!S>>DQAGaKa1d1gkcCQ<DGqL
)Q$q'\
:d1gl
KC	vc{{ 1gk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*.
    )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6$DzT||F##4:a=!! 1 171:??aaadd1gaj0DAJ7DGT!W$$r   c                 V    t          j        | ||t          j        |           g          S rC   )r   r	   	ones_like)rd   re   rf   s      r   r`   r`      s%    8RRb!1!12333r   c                 D    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                 D    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                 F    t          j        t          | |                    S rC   )r   column_stack_proj_trans_pointsry   s     r   rx   rx      s    ?-fa88999r   c                 "    t          | |          S rC   )r~   ry   s     r   proj_trans_pointsr      s    fa(((r   c                 @    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      sj    u$D	<<<tdUA&tT1%<<! 
" 
"B 6"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      sa             
 04- - - -, , , ,  "$ $ $N  .   ( > > >	 	 	 0 0 0      % % %4 4 4' ' '"ODO	J[ " " ""02 2	
, , , # # #: : : ) ) )) ) )
     r   