U
    -eE                     @   s,  d dl mZ d dlmZ d dlmZ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mZ d dlmZ d dlmZ d dlmZmZ d dlmZmZmZ d d	l m!Z! d
d Z"dd Z#e!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,d d! Z-d"d# Z.d$d% Z/d&d' Z0d(S ))    )Abs)sqrt)SRational)	decomposebest_origindistance_to_sidepolytope_integrate
point_sorthyperplane_parametersmain_integrate3dmain_integratepolygon_integratelineseg_integrateintegration_reductionintegration_reduction_dynamic	is_vertex)	Segment2D)Polygon)PointPoint2D)xyz)slowc                   C   s  t tdtikstt td dtd iks0tt tt dtt iksLtt tt dtt ikshtt td t ttd dkstt dtd  dt  d ddt dtd  dkstt td dt t  dtd dt t  ikstt d	td  t dt  td  td t  d ddt t d	td  td ttd   d
ks^tt tdthksttt td dtd hkstt tt dtt hkstt tt dtthkstt td t dttd hkstt dtd  dt  d dddt dtd  hks*tt td dt t  dtd dt t hks^tt d	td  t dt  td  td t  d ddtdt d	td  ttd  td hkstd S )N      r   r            )r   r   r      	   )r   r   r   r!   T)r   r   AssertionErrorr    r$   r$   c/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/sympy/integrals/tests/test_intpoly.pytest_decompose   s(    "842,
$:44&r&   c                  C   s  t d td  t d td   dt  td  t d t  } ttddtdd}tttdd dttdd d}ttdtdd tdtdd }ttddtdd}ttddtdd}ttddtdd}tdd|| d	ksttd
d|td dksttdd|td dks.ttdd|td t d  dksRttdd|td t d  d
ksvttdd|td t d  dksttdd|td t d  d
kstd S )Nr      r       r   r!   r   )r   r   r   r!   )r   r   )      ?r   )r   r   )r   r*   r   r   r"   )r   r   r   r   r   r   r#   )expr1l1l2l3l4l5l6r$   r$   r%   test_best_origin+   s    <&&$$$r3   c                  C   sp  t ttddtddtddddks,tt ttddtddtddtddtt tddksjtt ttddtddtdddtd  dt  td	dkstt ttddtdtdttdtdttddddkstttddttd d tj	ttd d tdd tddttdd tdd ttdd tj	} t | dtdtd d kstt d
ddgddkstt d
dddgtt tddkstt dddgdtd  dt  td	dkstt d
dtdfdftddfdfdgddks&ttddtd d fdfdtdd ftddtdd ftdftj	tdd ftdfdtdd ftj	td d fdfg} t | dtdtd d kstt ttddtddtddtddtddddkstt ttddtddtddtddtddtddddksRtt dddddgddksptt ddddddgddkstttddtddtdd td!d"td#dtd$d%td&d'}t |td tt  td  td(d) kstttd*d+td,d-td.d/td0d1td2d3}t |td tt  td  td4d5 ks\tttd6d7td8d9td:d;td<d=}t |td tt  td  td>d) kstttd?d@tdAdBtdCdDtdEdFtdGdH}t |td tt  td  tdIdJ kstttddtddtdd}g }tdK t tdL td   dtd  tdM   }td td  td td   dtdN   }tdN tdK t  tdM td   td td   }	|
|||	f t ||dNdO}
|
| tdPdQkst|
| tdRdSkst|
|	 tdTdUks(tttddtddtdd}tdL td  dtd  td   }td td  td td   dtdN   }tdN tdK t  tdM td   td td   }	|
|||	f t ||dKdOtdL t dtd  td   tdVdKikstt ttddtddtddtddddOddddttj	td td  tjdK td tjd td tjd ttj	ttd  tjd td tjd td tjd td t tjd td t tjdM tt tjd td tjd td tjd ttd  tjdM iks$tdWdXdYdZd[d\d]d^gddddgddddgddLddgddddLgddddLgddddgg}t |dtd_kstdWd`dadbdcdddedfgddLddgdddLdgddddLgddddgddddgddddgg}dWdcdgdhdidad`dddjdkdldbgddmddgddLddgddddddgdmdNddgdNdKddgdKdMddgdMdLddgdLdMdKdNdmdgg	}dWdndodptjd tjd tjd fgdddgdddgdddgdddgdddgdddgdddgg}t |td td  tt  td  tdqdk	stt |td td  tt  td  tdrds k
s$tt |td td  tt  td  tdtdu k
s\ttjtd ddfdtjtd dfddtjtd fddtjtd fdtjtd dftjtd ddfgdddgdddgdddgdddgdddgdddgdddgdddgg	}t |dtdd ks*tdvdwdxdydzd{d|d}d~dddddddddddgdsddddgddLdddgdKdddLdMgdddddgdddddgdmddddNgdMddddKgdNdddsdmgddddmdsgddNdddgddddKdgddMdLddgg}tt |dd dk sttd td  td  }ddddddddddddddddddddddddddddddgddNdgddNdgdddgdddgddNdgddNdgdddgdddgdddgdddgdddSgdSddgdddgdddgdddgdddgdddgdddgdddgdddgddMdgddMdgdddgdddgddKdLgdLdKdgdddLgdLddgdMdsdgddsdMgddmdKgdKdmdgdmddgdddmgdddsgdsddgddSdgdddgdddgddSdgg)}tt ||d dk stddddddddddddddddddddgddNddLgdddMdgdddMdNgddddLgddLddgdMdddNgdddmdgddKddsgdmdKddgddsddgddsddgdmdddKgdddmdLgdddMdsgddsdMdgdmdddLgddLddsgdMddmdgddNddgddKddgddKddgddddNgddddgddNddKgddddgddddgddddgddddgddddgddddgg}tt ||d dk s0tdddddddddddddddddddddddddddddddddddddddddddddddd ddddddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,g\dKd-d.gd/d0d1gdd2d3gd4d.d5gdd1d6gdsd3d7gd8d6d-gdd7d0gd9d5d2gdd6d:gdd;d<gdd=d>gdd:d?gdmd<d@gdd>d2gdAd@d6gdBd2d;gdd?d=gdd@d1gdCd5dDgddEdgdFd1dGgddDdHgdMdd=gdIdHd@gdJd=d5gdKdGdEgddHd<gdSd?d.gddLdMgdd<d0gdd.dNgddMdEgdOdNdHgddEd?gdPd0dLgddNdDgdQdGd:gdNd7dRgdSdDd;gdLd:d-gddRdLgdtd-dNgdTdLdGgdd;d7gdUd@dgdVdWdRgdJd5d>gdXddNgdPdRd0gdYd>dZgdd0d@gd[dZdWgddNd5gd\dHdgd]dZd3gdd?dgd^dd-gdd3d;gd_dd`gdd;dHgdad`dZgdLd-d?gdbdNdgdYd`d>gdTdGdMgdUdd6gd9d>d5gdcdMddgdd5dNgdeddd`gdd6dGgdXd-dgd_dddgdd0dRgd\dd@gddd?gdVdRdfgdKd?d-gdgdfddgdmd@d0gd^d6dgdcdfdMgdBd;d3gdbddHgdKdMdGgd]d3dWgddGd6gdhdWdfgddHd;gdd7d<gded`dgdtdNd.gdId<dHgdhddWgdSd.d=gdNdWd7gdMd=d`gdbdHdNgdSd2dDgdgdddgd8d-d:gdOdDdNgd[ddZgdQd:dEgddZd2gddEddgdXdNd-gd4d=d.gdhdfdgdAd6d1gdtd.d-gdadd`gd/d1dLgdd`d=gddLdfgd^d-d6gddEd:gd[dWdgdId@d<gd8d:d6gdedddgdd<d7gddddEgdsd7dWgdUd6d@gdFdLd1gdadZdgdOdHdDgdAd1d@gdgddfgdCdDd2gddfdLgdd2dZgd\d@dHgdd;dDgddfdRgdd=dgddDd5gddRd7gddddgdd7d;gdcdddfgd4d5d=gdd5d.gdsdWd3gdKdEdMgdKd.d?gdBd3d2gddMdfgdCd2d5gdVdfdWgdd?dEgdLd?d:gddZd>gdPdLdRgdd:dGgdJd>d=gdNdRdWgdSd=d?gd]dWdZgdFdGdLgddGd1gdMd`dgdd7d3gdd1d0gdddEgdd3dZgdQdEdGgdYdZd`gdd0d7gdmd0d<gddddMgd9d2d>gdd<d;gdTdMdLgdd>d`gd/dLd0gd_d`ddgdSd;d2gg}tt |ddi dk sTttt ||dj dk srtt |td tt gddOtt dktd td dktd ikstt |ddOddltdmtd tt dktd tdmtd tt dktd td dktd td dktd tdmtd tt dktd td dktd i
ksltd S (n  Nr   r   r   r   r!   r'      (   iY)r   r   )r   r   )r   r7   r   )r   r   r   )r   r   r   )r9   r!   ))r   r7   ))r;   r7   r7   r6   r:   )r6   r   ))r   r7   r   )r+   r   )r8   r   ))r7   r   r   ))r7   r7   r   gQ?gX9vgףp=
gPngT㥛 gʡEg(\gKgHzG	g1Zdg}?5^@gL7A`?gS@l   le4_9 l     QJgX9v>@gK7@gB`"?g
ףp=
g{Gz
gZd;O	zGagzGg-FgZd;?l   ;U(h*Y l     gQgh|?5gtV
g;O@gbX9gMg~jtgh|?5	l   Euj g5^I?grh|gFxg+@gʡE?gjt@gQ@g333333gMڿgNbX9l   K[+r l    J)r"   r    r   
   Z
max_degreei$iR  iP    iti  i.w r   r   r   )r   r4   r4   )r4   r4   r4   )r!   r4   r   )r   r4   r   )r4   r   r4   )r!   r   r   )r   r   r4      r   r   r'   r   r'   r   r   r'   r'   r'   r   r   r'   r   r'   r'   r'   r   r'   r'   r'   )r'   r   r   )r!   r   r   )r!   r'   r   )r'   r   r'   )r!   r   r'   )r!   r'   r'      r   r   r   r   r   r   r   r   r   i	=  i+  r(   %   i  )gaI{Կr   F8?)gaI{?r   F8ۿ)Sr   ׈?0?)S?r   ׈?0)rT   P/7ӿrO   )rT   P/7?rO   )rR   rU   rP   )rR   rV   rP   )aI{Ŀ      rR   )rW         ?rR   )aI{?rX   rT   )rZ   rY   rT   )rP   rU   rT   )rP   rV   rT   )Sпa-!r?rP   )r[   a-!rȿrP   )S?r\   rO   )r^   r]   rO   )rO   rU   rR   )rO   rV   rR                        gZ?g-q=)r   g;fr   )r   g;f?r   )ب/h?;fֿHH~?)rf   ;f?rh   )%D?SN%D?)rj   SN?rl   )HH~??z5˿HH~??)rn   z5?rp   )[ $?rg   %D׿)rr   ri   rs   )rh   r   rs   )HH~?ӿro   rh   )rt   rq   rh   )rp   r   rl   )~E?rk   r   )ru   rm   r   )rl   r   rh   )~Eڿrk   r   )rv   rm   r   )oro   r   )rw   rq   r   )o?ro   r   )rx   rq   r   )rs   r   rp   )[ $߿rg   rl   )ry   ri   rl   )%Dǿrk   rs   )rz   rm   rs   )ب/hrg   rp   )r{   ri   rp                              gÜ?gư>)rW   rX   ys)rW   rY   r   )rZ   rX   ys?)rZ   rY   r   )rQ   r   r   )rS   r   r   )r[   wrW   )r[   w?rW   )r^   r   rZ   )r^   r   rZ   )rP   rU   r   )rP   rV   r   )rO   rU   r   )rO   rV   r   )r   rX   rZ   )r   rY   rZ   )r   rX   rW   )r   rY   rW   )F8r   rW   )F8?r   rZ   g      ?)r   r   O)r   r   O@)r   Tͻr   )r   r   r   )r   Tͻ@r   )r   r   r   )wVnTͻr   )r   r   r   )r   Tͻ?r   )r   r   r   )wVn@r   r   )r   r   r   )r   r   r   )r   r   r   )r   ~jr   )r   r   r   )r   ~j@r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )k)#r   V)r   r   r   )k)#@r   V?)r   r   r   )1*Tͻ r   )r   Tͻ @r   )1*@r   r   )r   r   r   )gr,Er   q
)gr,E@r   q
@)r   r   r   )r   r   r   )r   r   r   )r   r   r   )A(`Rr   r   )r   r   r   )A(`R@r   r   )r   r   r   )Vr   r   )r   r   r   )r   r   r   )V@r   r   )r   r   r   )r   r   r   )r,Er   r   )r   r   r   )r,E?r   r   )r   r   r   )ysr   r   )r   r   r^   )ys?r   r   )r   r   r[   )r   r   r   )r   r   r   )r   r   r[   )r   r   r   )r   r   r[   )r   r   r   )r   r   r   )r   r   r   )r   r   r^   )r   r   r   )r   r   r^   )r   r   r   )r   r   r   )r   r   r   )r   rX   r   )r   rY   r   )r   Tͻr   )r   r   r   )r   r   r   )r   Tͻ@r   )r   rX   r   )r   rY   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )rP   r   r   )rP   r   r^   )rP   r   r   )rP   r   r^   )r[   r   r   )r[   r   r   )r^   r   r   )r^   r   r   )rO   r   r   )rO   r   r[   )rO   r   r   )rO   r   r[   B   /   ,   >   M   [   1   !   S   T   5   $   I   .   @   +   :   H   3   J   <   #   O   N   8   L   Q   K      *   )   Y   G   U   A   "       0   -   F   X   &   C   9   ;   W   ?   4   '   7      E   R   Z   6   D   2   V   P   =   gfI@g1:o@i5  }   iq  )r	   r   r   r#   r   r   r   r   r   HalfextendZOner   ZNegativeOner   )ZhexagonZfig1Zfig2Zfig3Zfig4Ztripolysr,   Zexpr2Zexpr3Zresult_dictZcube1Zcube2Zcube3Zcube4Z
octahedronZgreat_stellated_dodecahedronexprZoctahedron_five_compoundZcube_five_compoundZechidnahedronr$   r$   r%   test_polytope_integrate@   s      $
 

 
$ 
  
 
 
  

 

 

 

0,4$,4(
     
   
 
    
 
   
 
 
 

 

  
 
 
 

 

     
 
  

 
 
      $
$

$

$              

.                          <

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 
&\               
   
                        
               
                                              
  
                  
  
            
&

4          r   c                  C   s   t tddtddtddgtddtddtddgks@ttddd} t| tt tddkshtt| tt dd	tddkstd S )
Nr   r   r   r   r:   r+   r7   r   T)Z	clockwise)	r
   r   r   r#   r   r	   r   r   r   )fig6r$   r$   r%   test_point_sort  s    r   c                  C   s   t tddtddtddtddtd	d
tddtddtdd} t| td tt  td  tdd ksttt tddtddtddtddtdd}t|td tt  td  tdd kstd S ) Ng)\g9vgMbXgJ+?gT㥛 
gX9v?gq=
ףpgp=
ף g/$
@gB`"g$C@r=   gGzg\(\@g&1g9v
r   l   #ShK6. l     ^OWg/$g1Zg|?5^g/$@gGzgX9vgMb@gy&1gZd;@gd;O?l   QMQ@ l    0{
)r   r   r	   r   r   r   r#   )Zfig5r   r$   r$   r%   !test_polytopes_intersecting_sides  s&       
 
r   c                  C   s   t dddd} dtttt td t ttd  g}t| |ddddttjttjtt tdd	td t tdd
ttd  tdd
ikstt| |ddddttjttjtt tdd	ikstt| |ddddttjttjikstd S )Nr   r9   r+   r:   r   r   r!   r?   r   r4   )r   r   r   r	   r   r   r   r#   polygonr   r$   r$   r%   test_max_degree  s    $D r   c                  C   s   ddddddddgd	d
ddgddddgdd
ddgddddgdddd	gddd
d	gg} | d }| dd  }t ||}td|||dksttd|||ddddttdd	ttdd	ttdd	ikstd S )NrA   rC   rD   rE   rF   rG   rH   rI   r   r4   r    r!   r'   r   r   r   ir?   i)r   r   r#   r   r   r   r   )cubeverticesZfaces	hp_paramsr$   r$   r%   test_main_integrate3d!  s&    
  
 
 
 

 

$r   c               	   C   s~   t ddd} | j}t| }ttd td  ||tddks@tttd td  ||ddd	d	dd
ttddtdiksztd S )Nr)   )r'   r!   r+   r   iE  r4   r   r?   r   r'   r   r!   r>   )r   sidesr   r   r   r   r   r#   )trianglefacetsr   r$   r$   r%   test_main_integrate.  s    &r   c               
   C   s   ddddddddgd	d
ddgddddgdd
ddgddddgdddd	gddd
d	gg} | d }| dd  }| d }t |ddgd||dddkstd S )NrA   rC   rD   rE   rF   rG   rH   rI   r   r4   r    r!   r'   r   r   r   rL   i)r   r#   )r   Zfacetr   r   r$   r$   r%   test_polygon_integrate7  s     
  
 
 
 

 
r   c                  C   s*   d} t | ddgdtd d ks&td S )NrA   rM   rL   rK   r   )r   r   r#   )pointr$   r$   r%   test_distance_to_sideB  s    r   c                  C   sH   ddddg} ddg}t | d|dddks,tt | d|dddksDtd S )NrD   rH   rI   rE   r   r   r'   )r   r#   )r   Zline_segr$   r$   r%   test_lineseg_integrateG  s    r   c                  C   sx   t tddtddtdd} | j}t| d \}}t|d||dttfddksTtt|d||dttfddksttd S )Nr   r!   r'   r   )r   r   r   r   r   r   r   r#   )r   r   abr$   r$   r%   test_integration_reductionN  s
     r   c                  C   s   t tddtddtdd} | j}t| d \}}|d jd }ddddgddddgtdddgtddd gg}t|d||tdttfddd||dtddkst	t|d||ddttfddd||ddkst	d S )Nr   r!   r'   r   rd   r   r   )
r   r   r   r   Zpointsr   r   r   r   r#   )r   r   r   r   Zx0Zmonomial_valuesr$   r$   r%   "test_integration_reduction_dynamicV  s4    
 
        r  c                   C   sZ   t ddkstt ddks tt tdddks6tt ddksFtt ddksVtd S )Nr   F)r   r!   Tr!   )r   r!   r   )r   r!   r   r'   )r   r#   r   r$   r$   r$   r%   test_is_vertexd  s
    r  c                  C   s,  t tddtddtddtdd} dtttt td t ttd  g}t| |ddttjttjtt tddtd t tddttd  tddikstdtttt dtd t  tttd   g}t| |ddttjttjtt tddtd t d tddttd  t tddiks(td S )Nr   r   r   r   r4   r!   re   )	r   r   r   r   r	   r   r   r   r#   r   r$   r$   r%   test_issue_19234l  s    &$D,Lr  N)1Z$sympy.functions.elementary.complexesr   Z(sympy.functions.elementary.miscellaneousr   Z
sympy.corer   r   Zsympy.integrals.intpolyr   r   r   r	   r
   r   r   r   r   r   r   r   r   Zsympy.geometry.liner   Zsympy.geometry.polygonr   Zsympy.geometry.pointr   r   Z	sympy.abcr   r   r   Zsympy.testing.pytestr   r&   r3   r   r   r   r   r   r   r   r   r   r   r  r  r  r$   r$   r$   r%   <module>   s6   <
   @		