o
    tBh5                     @   s   d Z ddlZddlmZ dd 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eZdd Zdd Zdd Zdd ZdS ) z,
Various transforms used for by the 3D code
    Nc           	      C   s   t |d | d  }t |d | d  }t | |kr#t ||S |d | d  }|d | d  }|| ||  |d |d   }t |dd}t |||  |||  }|S )a2  
    Return the distance(s) from line defined by p1 - p2 to point(s) p0.

    p0[0] = x(s)
    p0[1] = y(s)

    intersection point p = p1 + u*(p2-p1)
    and intersection point lies within segment if u is between 0 and 1.

    If p1 and p2 are identical, the distance between them and p0 is returned.
    r         )npasarrayallhypotclip)	p1p2p0x01y01x21y21ud r   r/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mpl_toolkits/mplot3d/proj3d.py_line2d_seg_dist	   s    r   c              	   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.
    Nr   r   r   r   r   r   r   array)xminxmaxyminymaxzminzmax	pb_aspectdxdydzaxayazr   r   r   world_transformation$   s   
r%   c                 C   s   | | }|t j| }t ||}|t j| }t ||}|d |d |d dg|d |d |d dg|d |d |d dgg dg}ddd| d  gddd| d  gddd| d  gg dg}t ||S )Nr   r   r   r   )r   linalgnormcrossdot)ERVnr   vMrMtr   r   r   view_transformation:   s    r1   c                 C   sJ   | | | |  }d| |  | |  }t g dg ddd||gg dgS )Nr   r   r   r   )r   r   r   r   r   )r   r   r   r   zfrontzbackabr   r   r   persp_transformationZ   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   r2   r   r   r   r5   r   r   r   ortho_transformationc   s   



r;   c                 C   sF   t || }|d }|d | |d | |d | }}}|||fS N   r   r   r   )r   r)   )vecMvecwwtxstystzsr   r   r   _proj_transform_vecm   s   (
rE   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 r<   )r   r)   any)r>   r?   r@   rA   rB   rC   rD   tisr   r   r   _proj_transform_vec_clipu   s   (0
rH   c                 C   s\   t |}t| ||}t||}z||d  }W n	 ty"   Y nw |d |d |d fS r<   )r&   inv_vec_pad_onesr   r)   OverflowError)xsyszsr?   iMr>   vecrr   r   r   inv_transform   s   
rQ   c                 C   s   t | ||t | gS N)r   r   	ones_like)rL   rM   rN   r   r   r   rJ      s   rJ   c                 C      t | ||}t||S )z7
    Transform the points by the projection matrix
    )rJ   rE   rL   rM   rN   r?   r>   r   r   r   proj_transform   s   
rV   c                 C   rT   )zy
    Transform the points by the projection matrix
    and return the clipping result
    returns txs, tys, tzs, tis
    )rJ   rH   rU   r   r   r   proj_transform_clip   s   
rW   c                 C   s   t t| |S rR   )r   column_stackproj_trans_points)pointsr?   r   r   r   proj_points   s   r[   c                 C   s   t |  \}}}t||||S rR   )ziprV   )rZ   r?   rL   rM   rN   r   r   r   rY      s   rY   c                 C   sN   t |t |}}t g dd|| dgd||dgg dg}t || S )Nr3   r   r   )r   cossinr   r)   )r,   alphacosasinaM1r   r   r   rot_x   s   

rc   rR   )__doc__numpyr   numpy.linalgr&   r   r%   r1   r:   r;   rE   rH   rQ   rJ   rV   	transformrW   r[   rY   rc   r   r   r   r   <module>   s&    
 	

