U
    L?h                     @   s   d dl mZmZmZmZ d dlmZmZmZ d dl	m
Z
mZmZ d dlmZmZ d dlmZmZmZmZ d dlmZ dd Zd	d
 Zdd Zdd ZdS )    )R2R2_pR2_rR3_r)intcurve_seriesDifferentialWedgeProduct)symbolsFunction
Derivative)trigsimpsimplify)sqrtatan2sincos)Matrixc                  C   sl  t ddd\} }}}t ddd\}}td}tt| |gtt| d |d  t|| gksft	tt||gt|t
| |t| gkst	tt||gtt
|| t| gt||t
| ggkst	|tjtj}t| |g}tt| d |d  t|| g}	|||| |ks6t	||	|| |ksPt	t| |g}
t||g}t|
| kst	t||t
| kst	t||kst	t|
t| d |d  kst	t|
t|| kst	tjtjd  tjd  }||
| | d |d   |d  ks4t	|||d t|d  |d t
|  ksht	d S )Nzx0, y0, r0, theta0Trealzx, yf      )r	   r
   r   Zpoint_to_coordsr   pointr   r   r   AssertionErrorr   r   Zjacobianr   xyrcallrtheta)x0y0r0theta0r   r   r   fieldZ
p1_in_rectZp1_in_polarp_rp_ph r'   b/var/www/html/venv/lib/python3.8/site-packages/sympy/diffgeom/tests/test_function_diffgeom_book.pytest_functional_diffgeom_ch2   s6     (
$$,r)   c                     s  t ddd\} }t ddd\}} td}td}td}t| |g}|tjtj}|tjtj |tjtj  }	|		|	|
 || t|| ||  ||t|| ||  kstttjd 	|d|  ksttjdtj  }
tjd d	tj  }|
	|	|
 d|  d
|  d	 ks2ttj tj tjtj  }t| tddgdd}t| \}}t fddt|D stt fddt|D std S )Nzx0, y0Tr   zx, y, tr   b1b2r   r         r   )Zcoeffsc                 3   s&   | ]\}}|t  | kV  qd S N)r   taylor_term.0itermtr'   r(   	<genexpr>G   s    z/test_functional_diffgeom_ch3.<locals>.<genexpr>c                 3   s&   | ]\}}|t  | kV  qd S r.   )r   r/   r0   r4   r'   r(   r6   I   s    )r	   r
   r   r   r   r   r   e_xe_yr   doitr   r   r   r   zipall	enumerate)r   r    r   r   r   r*   r+   r$   Zs_fieldZv_fieldvscircZseriesZseries_xZseries_yr'   r4   r(   test_functional_diffgeom_ch32   s8     
".r@   c                  C   s  t ddd\} }}t ddd\}}}}t ddd}td}td}	td	}
t| |g}t||g}|	tjtjtj |
tjtjtj	  }|
tj
||	| |kst|
tj
||
| |kst|tjtj}t|}|tj
| t|| || kst|tj
| t|| ||ks8t|tjtj}t|}t|tj
| t|t|||| t|t|||| |  kstt|tj
| t|t|||| t|t|||| |  kstttj
|d
kstttjd
ks$tttj
|dks@tttjdksVttj tj tjtj  }t|
| | kstt	|
|| kstt|
|dksttt|
|d
kst|tj 
|
|dkstd S )Nzx0, y0, theta0Tr   zx, y, r, thetar!   )Zpositiver   r*   r+   r-   r   )r	   r
   r   r   r   r   r   r   dxdyr   r7   r   r8   r   r9   r   r   r   r   r   r   Zdrr   dthetaZe_theta)r   r    r"   r   r   r   r   r!   r   r*   r+   r$   r%   Zf_fieldZ	s_field_rdfZ	s_field_pr?   r'   r'   r(   test_functional_diffgeom_ch4M   sJ    (  **

 rE   c                  C   s  t ddd\	} }}}}}}}}| tj |tj  }	|tj |tj  }
ttjtj}||	|
| | ||  ksrt| tj |tj  |tj	  }	|tj |tj  |tj	  }
|tj |tj  |tj	  }ttjtjtj
}||	|
|tdd| ||||||||g	 kstt dtd\}}}|tjtjtj}|tjtjtj}|tjtjtj}|tj |tj  |tj
  }t|}t|}t|}t|}|t|tj t|tj t|tj
 }|tjtjdkstd S )Nzu0:3, v0:3, w0:3Tr   r   za, b, c)clsr   )r	   r   r7   r8   r   rA   rB   r   r   Ze_zZdzr   Zdetr
   r   r   zr   r   )Zu0u1u2Zv0Zv1Zv2Zw0Zw1Zw2ur=   ZwpwabcZa_fZb_fZc_fr   rC   dadbZdcexprr'   r'   r(   test_functional_diffgeom_ch6w   sD       
 

rR   N)Zsympy.diffgeom.rnr   r   r   r   Zsympy.diffgeomr   r   r   Z
sympy.corer	   r
   r   Zsympy.simplifyr   r   Zsympy.functionsr   r   r   r   Zsympy.matricesr   r)   r@   rE   rR   r'   r'   r'   r(   <module>   s    *