U
    @f                     @   s  d dl Z d dlmZ d dlmZmZ d dlmZ d dlm	Z	 d dl
mZmZmZmZmZmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZ d d	l m!Z!m"Z"m#Z#m$Z$m%Z% d d
l&m'Z' d dl(m)Z) dd Z*dd Z+dd Z,dd Z-dd Z.dd Z/dS )    N)Float)
DerivativeFunction)S)Symbol)expcossintancoshsinh)sqrt)PointPoint2DLinePolygonSegmentconvex_hullintersectioncentroidPoint3DLine3DRayEllipse)idiffclosest_pointsfarthest_points_ordered_pointsare_coplanar)solve)raisesc                     s*  t dddt ddd} t ddd}td}td}d | d  d	 }d
 d | d  d  | d  }|t|| dkstt|| d|t|| gdkstt|| d|kstd td  d	 d   || t|| d  std fddt|| D ks tt| |  | |gt| d ksNtt|t	| t	  |d t	 t	|  |d  kstt|| t	  || g| t|  t	 kstt|| t	  | |g|  t|t	   ks2tt|| ||gt|ksjt| dt
 d  d  td  dtd    }t|| dt
 t dtd   dt  td d  dt   dt
 d   dd   ks&td S )NxT)realytfg                  r   c                    s   g | ]}| d  qS )r+   )Zdiffequals).0Zsolexplicitr!    B/tmp/pip-unpacked-wheel-6uje5nh9/sympy/geometry/tests/test_util.py
<listcomp>   s     ztest_idiff.<locals>.<listcomp>i
   i   )r   r   r   AssertionErrorr   subsr   r.   r   r   r	   r
   r   r   r   )r#   r$   r%   r&   circansZfxyr2   r0   r3   
test_idiff   s<    $$ $.\@H8:,

r;   c                  C   s  t tddg kstttdd  t tddtddtddd	d
tddtddgks^tt tddtddtddd	d
tddtddgkstt tddtddtddtdddd	d
tddtddgkstd} t ttddtddt	tdd| ddd	d
d j
}|ttddddj
ks6ttdd} t ttddtddt	tdd| ddd	d
d j
}|ttddddj
kst|d jdkst|d jdkstd S )Nr   c                   S   s   t tdddS Nr   r+   )r   r   r2   r2   r2   r3   <lambda>+       z#test_intersection.<locals>.<lambda>r   r   r'   r   )r   )r*   r   )r   r*   T)Zpairwiser*   )Zslopeg      @gMbP?rA   g-C6J?g333333g       @)centerZhradiusZvradiusgj6gG?gpF)evaluater(   r-   5   r6   )r   r   r7   r    	TypeErrorr   r   r   r   r   ZcoordinatespytestZapproxr   Z_prec)Rcc2r2   r2   r3   test_intersection)   sz        
  
 

 rJ   c                  C   sj   t tdd  dddddg} t| dd	itd
dtddtddtddgtd
dtddgfksftd S )Nc                   S   s   t tdddS r<   )r   r   r2   r2   r2   r3   r=   P   r>   z"test_convex_hull.<locals>.<lambda>r*   rA   r*   r+   rA   rM      ZpolygonFrP   rM   r*   rA   r+   rR   rS   )r    rE   r   r   r7   )pointsr2   r2   r3   test_convex_hullO   s    "rU   c                  C   s   t ddd} | dd}t| |tddd ks4ttdd} tdd	}t| |td
td d ksjtttddtddtddd kstttddtddtddtddd kstd S )Nr?   )r5   r   )r5   r5   r   r6   (   r+   r@   )r'   r'   r*   r'   )r   	translater   r   r7   r   r   )pqr2   r2   r3   test_centroidW   s    

"(rZ   c                     sB  ddl m}  ddlm} ttfD ]}|tkr4t nt tt	 fdd t
ddt
ddt
ddg}t
ddt
ddt
ddg}t
ddt
ddt
dd	g}t
ddt
ddt
d
dg}t
ddt
ddt
ddg}t
ddt
ddt
ddt
ddg}tddd}	dd |	df|	d df|	d dffD }
|||||||
fD ]`}|dd |t|dD }t | d  }\}}|||kst|t|ks@tq@t }t|dkr|t
| dd| dd qt|}|dd ||dD }t | d  }\}}|||ks"t|t|ks tq t
ddt
ddt
tjtdd   }}}dd ||||fdD }t||||kstt||||kstdddddg}t| t
ddt
dd
fhkstdd d!d"d#g}t| t
dd$t
dd%fhks
ttdd&t
ddt
ddfhks0ttt	d'd  d S )(Nr   )randint)subsetsc                      s    t ddt ddS )Nr   r   r2   funcr2   r3   r=   l   r>   z5test_farthest_points_closest_points.<locals>.<lambda>r+   r*   r'   r5   r(   rA   r!   T)Zpositivec                 S   s   g | ]}t |qS r2   r]   )r/   ar2   r2   r3   r4   |   s     z7test_farthest_points_closest_points.<locals>.<listcomp>c                 s   s   | ]\}}| |V  qd S Ndistancer/   ijr2   r2   r3   	<genexpr>   s     z6test_farthest_points_closest_points.<locals>.<genexpr>   d   c                 s   s   | ]\}}| |V  qd S ra   rb   rd   r2   r2   r3   rg      s     c                 S   s   h | ]\}}t ||fqS r2   )r   rd   r2   r2   r3   	<setcomp>   s   z6test_farthest_points_closest_points.<locals>.<setcomp>r*   r*   )r*   r'   )r+   r*   )rP   r'   )rR   r(   rP   rR   rK   rL   rN   rO   rQ   rM   rS   r?   c                   S   s   t dS )Nrk   )r   r2   r2   r2   r3   r=      r>   )Zsympy.core.randomr[   Zsympy.utilities.iterablesr\   minmaxr   r   r    
ValueErrorr   r   setlistrc   r7   r   lenaddr   ZHalfr   )r[   r\   howp1p2Zp3Zp4Zp5dupr!   srT   dr:   r`   brH   r2   r^   r3   #test_farthest_points_closest_pointsb   sb    $(   
rz   c                  C   s   t tdddtddd} t tdddtddd}t tdddtddd}ttddtdd}t| ||dksxtt| |dkstd S )	Nr-   r   r*   rA   rM   r+   	   F)r   r   r   r   r   r7   )r`   ry   rH   rx   r2   r2   r3   test_are_coplanar   s    r|   )0rF   Zsympy.core.numbersr   Zsympy.core.functionr   r   Zsympy.core.singletonr   Zsympy.core.symbolr   Zsympy.functionsr   r   r	   r
   r   r   Z(sympy.functions.elementary.miscellaneousr   Zsympy.geometryr   r   r   r   r   r   r   r   r   r   r   r   Zsympy.geometry.utilr   r   r   r   r   Zsympy.solvers.solversr   Zsympy.testing.pytestr    r;   rJ   rU   rZ   rz   r|   r2   r2   r2   r3   <module>   s     8&A