o
    i                     @   s$  d Z ddlZddlmZ 	d2ddZeddd Zd	d
 Zdd Z	dd Z
eddd Zeddd Zdd Zeddd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zejdd#d$d"d%eZd&d' Zedd(d) Zd*d+ Zedd,d- Zd.d/ Zedd0d1 ZdS )3z,
Various transforms used for by the 3D code
    N)_apic              	   C   s   ||  }|| }|| }	|dur!|\}
}}||
 }|| }|	| }	t d| dd|  | gdd| d| | gddd|	 | |	 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)ZxminZxmaxZyminZymaxZzminZzmaxZ	pb_aspectZdxZdyZdzaxZayaz r
   j/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/mpl_toolkits/mplot3d/proj3d.pyworld_transformation
   s   
r   z3.8c                 C   
   t | |S )K
    Produce a rotation matrix for an angle in radians about a vector.
    )_rotation_about_vector)vangler
   r
   r   rotation_about_vector    s   
r   c           	      C   s   | t j|  \}}}t |}t |}dt |d d  }t || | | || | ||  || | ||  g|| | ||  || | | || | ||  g|| | ||  || | ||  || | | gg}|S )r      )r   linalgnormsincosr   )	r   r   ZvxZvyZvzsctRr
   r
   r   r   (   s   

444r   c                 C   sv   | | }|t j| }t ||}|t j| }t ||}|dkr6t|| }t ||}t ||}|||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   ZRrollr
   r
   r   
_view_axes9   s   
r#   c                 C   sP   t d}t d}| ||g|ddddf< | |dddf< t ||}|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   )r"   r   r!   r   ZMrZMtMr
   r
   r   _view_transformation_uvw`   s   

r)   c                 C   s&   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.
    )r#   r)   )r   r   r   r    r"   r   r!   r(   r
   r
   r   view_transformationw   s   r*   c                 C   s   t | ||S N)_persp_transformation)zfrontzbackfocal_lengthr
   r
   r   persp_transformation   s   r0   c                 C   sb   |}d}| | | |  }d| |  | |  }t |dddgd|| ddgdd||gg dg}|S )Nr   r   )r   r   r&   r   r   )r-   r.   r/   eabr   proj_matrixr
   r
   r   r,      s   
r,   c                 C   r   r+   )_ortho_transformation)r-   r.   r
   r
   r   ortho_transformation      
r7   c              	   C   s>   | |  }| |  }t g dg dg ddd||gg}|S )N)r   r   r   r   )r   r   r   r   )r   r   r1   r   r   r   )r-   r.   r3   r4   r5   r
   r
   r   r6      s   



r6   c                 C   sF   t || }|d }|d | |d | |d | }}}|||fS Nr%   r   r   r   )r   r   )vecr(   vecwr!   txstystzsr
   r
   r   _proj_transform_vec   s   (
r?   c                 C   s   t || }|d }|d | |d | |d | }}}d|d k|d dk@ d|d k@ |d dk@ }t |rA|d dk }||||fS r9   )r   r   any)r:   r(   r;   r!   r<   r=   r>   Ztisr
   r
   r   _proj_transform_vec_clip   s   (0
rA   c                 C   s   t | ||}t||}|jdkr|d}t|jd D ]}|d | dkr;|dd|f |d |  |dd|f< q|d |d |d fS )zO
    Transform the points by the inverse of the projection matrix, *invM*.
    )r$   )r$   r   r   r%   r   Nr   )_vec_pad_onesr   r   shapeZreshaperange)xsyszsZinvMr:   Zvecrir
   r
   r   inv_transform   s   

(rI   c                 C   s   t | ||t | gS r+   )r   r   Z	ones_like)rE   rF   rG   r
   r
   r   rB      s   rB   c                 C      t | ||}t||S )z<
    Transform the points by the projection matrix *M*.
    )rB   r?   rE   rF   rG   r(   r:   r
   r
   r   proj_transform   s   
rL   function	transform)obj_typenamealternativec                 C   rJ   )zy
    Transform the points by the projection matrix
    and return the clipping result
    returns txs, tys, tzs, tis
    )rB   rA   rK   r
   r
   r   proj_transform_clip   s   
rR   c                 C   r   r+   )_proj_pointspointsr(   r
   r
   r   proj_points   r8   rV   c                 C   s   t t| |S r+   )r   Zcolumn_stack_proj_trans_pointsrT   r
   r
   r   rS      s   rS   c                 C   r   r+   )rW   rT   r
   r
   r   proj_trans_points   r8   rX   c                 C   s   t |  \}}}t||||S r+   )ziprL   )rU   r(   rE   rF   rG   r
   r
   r   rW      s   rW   c                 C   sN   t |t |}}t g dd|| dgd||dgg dg}t || S )N)r   r   r   r   r   r   )r   r   r   r   r   )r   alphaZcosaZsinaZM1r
   r
   r   rot_x   s   

r[   r+   )__doc__numpyr   Z
matplotlibr   r   
deprecatedr   r   r#   r)   r*   r0   r,   r7   r6   r?   rA   rI   rB   rL   rN   rR   rV   rS   rX   rW   r[   r
   r
   r
   r   <module>   sL    

'





