
    G8cL                     ~    d Z ddlZddlmZ d Z	 ddZd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZeZd Zd Zd Zd Zy)z,
Various transforms used for by the 3D code
    Nc                    t        j                  |d         | d   z
  }t        j                  |d         | d   z
  }t        j                  | dd |dd k(        rt        j                  ||      S |d   | d   z
  }|d   | d   z
  }||z  ||z  z   |dz  |dz  z   z  }t        j                  |dd      }t        j                  |||z  z
  |||z  z
        }|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ds	            =/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/proj3d.py_line2d_seg_distr   	   s     **RU
be
#C
**RU
be
#C	vvb1gAa !xxS!!
Q%"Q%-C
Q%"Q%-C	S3s7	sAvQ/A
1aA
qucAcEk*AH    c           	          || 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   r   r   array)xminxmaxyminymaxzminzmax	pb_aspectdxdydzaxayazs                r   world_transformationr(   $   s     
B	B	B
B
b
b
b88adA!b1AbD!b1A!B$b1*, - -r   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   )r   linalgnormsincosr   )	vanglevxvyvzsctRs	            r   rotation_about_vectorr7   :   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                    | |z
  }|t         j                  j                  |      z  }t        j                  ||      }|t         j                  j                  |      z  }t        j                  ||      }|dk7  r9t	        ||       }t        j
                  ||      }t        j
                  ||      }t        j                  d      }t        j                  d      }	|||g|d dd df<   |  |	d ddf<   t        j
                  ||	      S )Nr         )r   r*   r+   crossr7   doteye)
Er6   Vrollnr   r.   RrollMrMts
             r   view_transformationrF   K   s    	
QA	"))..
A
AA	"))..
A
AA qy%a$/FF5!FF5!	B	BQBrr2A2vJBrr2vJ66"b>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   )zfrontzbackfocal_lengtheabr4   proj_matrixs           r   persp_transformationrP   a   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   rH   r   r   r   )rI   rJ   rM   rN   rO   s        r   ortho_transformationrR   m   sH    
5.A
5.A((M))AqM+ ,K r   c                 r    t        j                  ||       }|d   }|d   |z  |d   |z  |d   |z  }}}|||fS Nr:   r   r   r   )r   r=   )vecMvecwwtxstystzss          r   _proj_transform_vecr\   x   sK    66!S>DQAGAItAwqy$q'!)cCS=r   c                     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   rV   rW   rX   rY   rZ   r[   tiss           r   _proj_transform_vec_clipr`      s    66!S>DQAGaKa1d1gkcCQ<DGqL
)Q$q'\
:d1gl
KC	vvc{1gkS#r   c                     t        j                  |      }t        | ||      }t        j                  ||      }	 ||d   z  }|d   |d   |d   fS # t
        $ r Y w xY wrT   )r*   inv_vec_pad_onesr   r=   OverflowError)xsyszsrV   iMrU   vecrs          r   inv_transformrj      sm    	AB
B
#C66"c?Dd1g~ 7DGT!W$$  s   A 	AAc                 Z    t        j                  | ||t        j                  |       g      S N)r   r   	ones_like)re   rf   rg   s      r   rc   rc      s#    88RRb!1233r   c                 4    t        | ||      }t        ||      S )z7
    Transform the points by the projection matrix
    )rc   r\   re   rf   rg   rV   rU   s        r   proj_transformrp      s     B
#CsA&&r   c                 4    t        | ||      }t        ||      S )zy
    Transform the points by the projection matrix
    and return the clipping result
    returns txs, tys, tzs, tis
    )rc   r`   ro   s        r   proj_transform_cliprr      s     B
#C#C++r   c                 @    t        j                  t        | |            S rl   )r   column_stackproj_trans_points)pointsrV   s     r   proj_pointsrw      s    ??,VQ788r   c                 6    t        |  \  }}}t        ||||      S rl   )ziprp   )rv   rV   re   rf   rg   s        r   ru   ru      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=   )r@   alphacosasinaM1s        r   rot_xr      s_    u$D	<tdUA&tT1%! 
"B 66"a=r   rl   )__doc__numpyr   numpy.linalgr*   r   r(   r7   rF   rP   rR   r\   r`   rj   rc   rp   	transformrr   rw   ru   r    r   r   <module>r      si     : 04-,",	%4' 	,9)
r   