o
    j                     @   s   d Z ddlZddlmZ 	d#ddZdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zeddd Zdd Zdd  Zd!d" ZdS )$z,
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	   \/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/mpl_toolkits/mplot3d/proj3d.pyworld_transformation
   s   
r   c           	      C   s   | t j|  \}}}t |}t |}dt |d d  }t || | | || | ||  || | ||  g|| | ||  || | | || | ||  g|| | ||  || | ||  || | | gg}|S )zK
    Produce a rotation matrix for an angle in radians about a vector.
       )r   linalgnormsincosr   )	vZangleZvxZvyZvzsctRr	   r	   r
   _rotation_about_vector    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   VZrollwur   ZRrollr	   r	   r
   
_view_axes1   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_uvwX   s   

r#   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   )zfrontzbackfocal_lengtheabr   proj_matrixr	   r	   r
   _persp_transformationo   s   
r,   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   r$   r   r   r   )r%   r&   r)   r*   r+   r	   r	   r
   _ortho_transformation{   s   



r-   c                 C   s   t || j}|d }|d | |d | |d | }}}t j| d r2t jj|| d jd}t j| d rEt jj|| d jd}t j| d rXt jj|| d jd}|||fS )Nr   r   r   r   )mask)r   r   datamaisMAr   r.   )vecr"   vecwr   txstystzsr	   r	   r
   _proj_transform_vec   s   (
r7   c           	      C   s  t || j}|d }|d | |d | |d | }}}t |r-t j|jtd}nd|k|dk@ d|k@ |dk@ |dk@ }t j| d rQ|| d j	 @ }t j| d ra|| d j	 @ }t j| d rq|| d j	 @ }t j
|| }t j
|| }t j
|| }||||fS )Nr   r   r   r   )Zdtyper    )r   r   r/   isinfZonesshapeboolr0   r1   r.   Zmasked_array)	r2   r"   r'   r3   r   r4   r5   r6   Ztisr	   r	   r
   _proj_transform_vec_clip   s    (
(r;   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   r9   Zreshaperange)xsyszsZinvMr2   Zvecrir	   r	   r
   inv_transform   s   

(rB   c                 C   sV   t j| st j|st j|rt j| ||t | gS t | ||t | gS N)r   r0   r1   r   Z	ones_like)r>   r?   r@   r	   r	   r
   r<      s   $r<   c                 C   s   t | ||}t||S )z<
    Transform the points by the projection matrix *M*.
    )r<   r7   )r>   r?   r@   r"   r2   r	   r	   r
   proj_transform   s   
rD   z3.10c                 C   s   t | |||tjdS )N)r'   )_proj_transform_clipr   inf)r>   r?   r@   r"   r	   r	   r
   proj_transform_clip   s   rG   c                 C   s   t | ||}t|||S )zy
    Transform the points by the projection matrix
    and return the clipping result
    returns txs, tys, tzs, tis
    )r<   r;   )r>   r?   r@   r"   r'   r2   r	   r	   r
   rE      s   rE   c                 C   s   t t| |S rC   )r   Zcolumn_stack_proj_trans_points)pointsr"   r	   r	   r
   _proj_points   s   rJ   c                 C   sL   t | } | d d df | d d df | d d df }}}t||||S )Nr   r   r   )r   Z
asanyarrayrD   )rI   r"   r>   r?   r@   r	   r	   r
   rH      s   
4rH   rC   )__doc__numpyr   Z
matplotlibr   r   r   r   r#   r,   r-   r7   r;   rB   r<   rD   
deprecatedrG   rE   rJ   rH   r	   r	   r	   r
   <module>   s(    
'

