U
    «Ģ0e<  ć                   @   sģ   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 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 )é    )Ś
DerivativeŚFunction)ŚS)ŚSymbol)ŚexpŚcosŚsinŚtanŚcoshŚsinh)Śsqrt)
ŚPointŚPoint2DŚLineŚPolygonŚSegmentŚconvex_hullŚintersectionŚcentroidŚPoint3DŚLine3D)Ś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stt|| d|t|| gdksØtt|| d|ks¾td td  d	 d   | | t|| d ”  ”sütd fddt|| D ks tt| |  | |gt| d ksNtt|t	| t	  |d t	 t	|  |d  ksŖtt|| t	  || g| t|  t	 ksźt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-_6tpq7m6/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fxyr/   r-   r0   Ś
test_idiff   s<    $$ $.\@H8:,
’’’’
’r8   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stt tddtddtddtdddd	d
tddtddgksÜtd S )Nr   c                   S   s   t tdddS ©Nr   r(   )r   r   r/   r/   r/   r0   Ś<lambda>)   ó    z#test_intersection.<locals>.<lambda>©r   r   ©r$   r   )é’’’’r   )r'   r   )r   r'   T)Zpairwiser'   )Zslope)r   r   r4   r   Ś	TypeErrorr   r   r/   r/   r/   r0   Śtest_intersection'   sB     ż ’ż ż ’ż
 ü ’ür@   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 r9   )r   r   r/   r/   r/   r0   r:   =   r;   z"test_convex_hull.<locals>.<lambda>©r'   r>   ©r'   éž’’’©r(   r>   ©éū’’’rC   ©é   éü’’’ZpolygonFrF   rC   r'   r>   r(   rH   rI   )r   r?   r   r   r4   )Śpointsr/   r/   r0   Śtest_convex_hull<   s    "žrK   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stttddtddtddtddd ksĀtd S )Nr<   )r2   r   )r2   r2   r   r3   é(   r(   r=   )r$   r$   r'   r$   )r   Ś	translater   r   r4   r   r   )ŚpŚqr/   r/   r0   Śtest_centroidD   s    

"(rP   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st|t|ks@tq@t }t|dkrÖ| t
| dd| dd” qØt|}|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stt||||ks¦tdddddg}t| t
ddt
dd
fhksŲt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   r/   ©Śfuncr/   r0   r:   Y   r;   z5test_farthest_points_closest_points.<locals>.<lambda>r(   r'   r$   r2   r%   r>   r   T)Zpositivec                 S   s   g | ]}t |qS r/   rS   )r,   Śar/   r/   r0   r1   i   s     z7test_farthest_points_closest_points.<locals>.<listcomp>c                 s   s   | ]\}}|  |”V  qd S ©N©Śdistance©r,   ŚiŚjr/   r/   r0   Ś	<genexpr>l   s     z6test_farthest_points_closest_points.<locals>.<genexpr>é   éd   c                 s   s   | ]\}}|  |”V  qd S rW   rX   rZ   r/   r/   r0   r]   w   s     c                 S   s   h | ]\}}t ||fqS r/   )r   rZ   r/   r/   r0   Ś	<setcomp>   s   ’z6test_farthest_points_closest_points.<locals>.<setcomp>©r'   r'   )r'   r$   )r(   r'   )rF   r$   )rH   r%   rF   rH   rA   rB   rD   rE   rG   rC   rI   r<   c                   S   s   t dS )Nra   )r   r/   r/   r/   r0   r:      r;   )Zsympy.core.randomrQ   Zsympy.utilities.iterablesrR   ŚminŚmaxr   r   r   Ś
ValueErrorr   r   ŚsetŚlistrY   r4   r   ŚlenŚaddr   ZHalfr   )rQ   rR   ŚhowŚp1Śp2Zp3Zp4Zp5Śdupr   ŚsrJ   Śdr7   rV   ŚbŚcr/   rT   r0   Ś#test_farthest_points_closest_pointsO   sb    $(   ’
’’’’rq   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std S )	Nr*   r   r'   r>   rC   r(   é	   F)r   r   r   r   r   r4   )rV   ro   rp   rn   r/   r/   r0   Śtest_are_coplanar   s    rs   N)+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   Zsympy.geometry.utilr   r   r   r   r   Zsympy.solvers.solversr   Zsympy.testing.pytestr   r8   r@   rK   rP   rq   rs   r/   r/   r/   r0   Ś<module>   s    0A