
    g                         d Z ddlZddlmZ 	 ddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Z ej                   d      d        Zd Zd Z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                X/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/mpl_toolkits/mplot3d/proj3d.pyworld_transformationr   
   s     
B	B	B
B
b
b
b88adqQb1AbDQb1q!B$b113 4 4    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 )zK
    Produce a rotation matrix for an angle in radians about a vector.
       )r   linalgnormsincosr   )	vanglevxvyvzsctRs	            r   _rotation_about_vectorr(       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_axesr2   1   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+   )r0   r   r/   r,   MrMtMs          r   _view_transformation_uvwr;   X   s`     
B	BQBrr2A2vJBrr2vJ
r2AHr   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   r6   r   r   )zfrontzbackfocal_lengtheabr%   proj_matrixs           r   _persp_transformationrE   o   sw    A	A	u%A
F5L6%<(A((Q!aO!aO!aO+- .K 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   r=   r   r   r   )r>   r?   rB   rC   rD   s        r   _ortho_transformationrG   {   sH    
5.A
5.A((M))AqM+ ,K r   c                 f   t        j                  || j                        }|d   }|d   |z  |d   |z  |d   |z  }}}t         j                  j	                  | d         r.t         j                  j                  || d   j                        }t         j                  j	                  | d         r.t         j                  j                  || d   j                        }t         j                  j	                  | d         r.t         j                  j                  || d   j                        }|||fS )Nr5   r   r   r   )mask)r   r+   datamaisMAr   rI   )vecr:   vecwr/   txstystzss          r   _proj_transform_vecrR      s    66!SXXDQAGAItAwqy$q'!)cC	uuzz#a&eekk#CFKKk0	uuzz#a&eekk#CFKKk0	uuzz#a&eekk#CFKKk0S=r   c                 <   t        j                  || j                        }|d   }|d   |z  |d   |z  |d   |z  }}}t        j                  |      r&t        j                  |j
                  t              }nd|k  |dk  z  d|k  z  |dk  z  |dk  z  }t         j                  j                  | d         r|| d   j                   z  }t         j                  j                  | d         r|| d   j                   z  }t         j                  j                  | d         r|| d   j                   z  }t         j                  j                  ||       }t         j                  j                  ||       }t         j                  j                  ||       }||||fS )Nr5   r   r   r   )dtyper6   )r   r+   rJ   isinfonesshapeboolrK   rL   rI   masked_array)	rM   r:   r@   rN   r/   rO   rP   rQ   tiss	            r   _proj_transform_vec_clipr[      s`   66!SXXDQAGaKa1d1gkcC	xxggciit,SySAX&")4qASAXN	uuzz#a&SV[[L 	uuzz#a&SV[[L 	uuzz#a&SV[[L 
%%

S3$
'C
%%

S3$
'C
%%

S3$
'C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*.
    )r4   )r4   r   r   r5   r   Nr   )_vec_pad_onesr   r+   rW   reshaperange)xsyszsinvMrM   vecris          r   inv_transformrf      s     B
#C66$DzzT||F#4::a=! 171:?add1gaj0DAJ1 7DGT!W$$r   c                    t         j                  j                  |       s>t         j                  j                  |      st         j                  j                  |      r6t         j                  j                  | ||t        j                  |       g      S t        j                  | ||t        j                  |       g      S N)r   rK   rL   r   	ones_like)r`   ra   rb   s      r   r]   r]      ss    	uuzz"~B255::b>uu{{BBR(89::xxRR\\"%5677r   c                 4    t        | ||      }t        ||      S )z<
    Transform the points by the projection matrix *M*.
    )r]   rR   )r`   ra   rb   r:   rM   s        r   proj_transformrk      s     B
#CsA&&r   z3.10c                 >    t        | |||t        j                        S )N)r@   )_proj_transform_clipr   inf)r`   ra   rb   r:   s       r   proj_transform_clipro      s    BABFFCCr   c                 6    t        | ||      }t        |||      S )zy
    Transform the points by the projection matrix
    and return the clipping result
    returns txs, tys, tzs, tis
    )r]   r[   )r`   ra   rb   r:   r@   rM   s         r   rm   rm      s!     B
#C#CL99r   c                 @    t        j                  t        | |            S rh   )r   column_stack_proj_trans_points)pointsr:   s     r   _proj_pointsru      s    ??-fa899r   c                 ~    t        j                  |       } | d d df   | d d df   | d d df   }}}t        ||||      S )Nr   r   r   )r   
asanyarrayrk   )rt   r:   r`   ra   rb   s        r   rs   rs      sF    ]]6"F1vad|VAqD\BB"b"a((r   rh   )__doc__numpyr   
matplotlibr   r   r(   r2   r;   rE   rG   rR   r[   rf   r]   rk   
deprecatedro   rm   ru   rs    r   r   <module>r}      s     
 044,"$N.	
*%8' D D::)r   