
    sg*                     &   d dl mZ d dlmZ d dl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mZmZmZ  ed      \  ZZZ ed      \  ZZZ ed	      Z ed
      Zedz  ej8                  z  eej:                  z  z   e e	e      z  ej<                  z  z   Zeej8                  z   e	e      ej:                  z  z   eez  ej<                  z  z   Z eej8                  z   ee      ej:                  z  z   ejC                         ez  ej<                  z  z
  Z"eez  ej8                  z  eez   ez  ej:                  z  z   edz  ez  ej<                  z  z   Z#edz  ej8                  ej:                  z  z  eej:                  ej:                  z  z  z   e e	e      z  ej<                  ej:                  z  z  z   Zeej8                  ej8                  z  z   e	e      ej:                  ej<                  z  z  z   eez  ej<                  ej8                  z  z  z   Zej8                  ej:                   ej<                  z
  z  Z$ej8                  ej:                  ej<                  z   z  Z%d Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d Z1d Z2d Z3d Z4d Z5y)    )Function)symbols)sqrt)asincossin)ReferenceFramedynamicsymbolsDyadic)VectorLatexPrintervpprintvsprint	vsstrreprvlatexa, b, czalpha, omega, betaAN   c                     t        | dd      S )NFuse_unicode	wrap_liner   exprs    [/var/www/html/venv/lib/python3.12/site-packages/sympy/physics/vector/tests/test_printing.pyascii_vprettyr      s    4Ue<<    c                     t        | dd      S )NTFr   r   r   s    r   unicode_vprettyr        s    4TU;;r   c                  x    t        d      d      } t               j                  | dz        dk(  sJ  t        d      d      }t               j                  |j                               dk(  sJ  t        d      d      }t               j                  |j                         j                               dk(  sJ y )	Nrtr   zr^{2}zr^2z\dot{r^{2}}r__az\ddot{r^{a}})r   r   doprintdiff)r"   r2ras      r   test_latex_printerr)   $   s    cA''Q/7:::	%	B''	2nDDD	&	#	B''	(89_LLLr   c                     d} d}t        t              | k(  sJ t        t              |k(  sJ d} d}t        t              | k(  sJ t        t              |k(  sJ d} d}t        t              | k(  sJ t        t              |k(  sJ t        t
        j                         dk(  sJ t        t
        j                         dk(  sJ t        dt
        j                  z        d	k(  sJ t        dt
        j                  z        d	k(  sJ y )
NzC 2                               
a  n_x + b n_y + c*sin(alpha) n_zu>    2                           
a  n_x + b n_y + c⋅sin(α) n_zz+alpha n_x + sin(omega) n_y + alpha*beta n_zu"   α n_x + sin(ω) n_y + α⋅β n_zzk                     2    
a       b + c       c     
- n_x + ----- n_y + -- n_z
b         a         b     u{                        2    
a       b + c       c     
─ n_x + ───── n_y + ── n_z
b         a         b     z-a_xr   0)r   vr    wor   xexpected	uexpecteds     r   test_vector_pretty_printr3   -   s
   HI
 x'''1***<H4Ix'''1***HI x'''1*** !##&(((ACC4 F*** 1333&&&1QSS5!S(((r   c                      t        d      \  } }}}}| dz  ||z  z   t        j                  z  t        |      t        j                  z  z   t        |      t        j                  z  z   }t        |      dk(  sJ t        d      \  }}}}|t        j                  z  ||z  t        j                  z  z   ||z  t        j                  z  z   }t        |      dk(  sJ t        d      \  }	}
}t        d      \  }}}t        |      t        j                  z  t        |	      t        |
      z  t        j                  z  z   t        ||z         t        j                  z  z   }t        |      dk(  sJ t        d	      }t        d      \  } }}}}| dz  ||z  z   |j                  z  t        |      |j                  z  z   t        |      |j                  z  z   }d
}t        |      |k(  sJ t        d	d      }| dz  ||z  z   |j                  z  t        |      |j                  z  z   t        |      |j                  z  z   }d}t        |      |k(  sJ d}t        t              |k(  sJ d}t        t              |k(  sJ d}t        t              |k(  sJ y )Nza, b, c, d, omegar   zs(a^{2} + \frac{b}{c})\mathbf{\hat{a}_x} + \sqrt{d}\mathbf{\hat{a}_y} + \cos{\left(\omega \right)}\mathbf{\hat{a}_z}ztheta, omega, alpha, qzT\theta\mathbf{\hat{a}_x} + \omega^{2}\mathbf{\hat{a}_y} + \alpha q\mathbf{\hat{a}_z}zphi1, phi2, phi3ztheta1, theta2, theta3z\sin{\left(\theta_{1} \right)}\mathbf{\hat{a}_x} + \cos{\left(\phi_{1} \right)} \cos{\left(\phi_{2} \right)}\mathbf{\hat{a}_y} + \cos{\left(\theta_{1} + \phi_{3} \right)}\mathbf{\hat{a}_z}r   zs(a^{2} + \frac{b}{c})\mathbf{\hat{n}_x} + \sqrt{d}\mathbf{\hat{n}_y} + \cos{\left(\omega \right)}\mathbf{\hat{n}_z})z\hat{i}z\hat{j}z\hat{k})latexszR(a^{2} + \frac{b}{c})\hat{i} + \sqrt{d}\hat{j} + \cos{\left(\omega \right)}\hat{k}z~\alpha\mathbf{\hat{n}_x} + \operatorname{asin}{\left(\omega \right)}\mathbf{\hat{n}_y} -  \beta \dot{\alpha}\mathbf{\hat{n}_z}z]- \mathbf{\hat{n}_x}\otimes \mathbf{\hat{n}_y} - \mathbf{\hat{n}_x}\otimes \mathbf{\hat{n}_z}z[\mathbf{\hat{n}_x}\otimes \mathbf{\hat{n}_y} + \mathbf{\hat{n}_x}\otimes \mathbf{\hat{n}_z})r   r   r/   r   yr   zr   r
   r   r	   wwxxxx2)abcdomegar,   thetaalphaqphi1phi2phi3theta1theta2theta3r   r1   s                    r   test_vector_latexrI   `   s    34Aq!Q	
a!a%133a133.Uacc1AAA!9 / 0 0 0
 ,,DEE5%eemacc))QY!##,==A!9 7 8 8 8 &&89D$$%=>FFF	Vqss		TSY		$
%	Vd]	acc	!
"A !9 @ A A A 	sA 34Aq!Q	
a!a%133a133.Uacc1AAA&H
 !9    	s#GHA	
a!a%133a133.Uacc1AAA5H !9   NH":!!!8H":!!!8H#;("""r   c                      t        t        j                  dz  d      dk(  sJ t        t        j                  dz  d      dk(  sJ y )N      @F	full_precz3.0\mathbf{\hat{n}_x}Tz"3.00000000000000\mathbf{\hat{n}_x})r   r   r/    r   r   test_vector_latex_argumentsrO      s>    !##)u-1IIII!##)t,0UUUUr   c                      t        d      } t        d      \  }}|j                         | j                  z  }t	        |      dk(  sJ |j                         |z  | j                  z  }t	        |      dk(  sJ y )Nr   zomega, alphaz\dot{\omega}\mathbf{\hat{n}_x}z'\dot{\omega}^{\alpha}\mathbf{\hat{n}_x})r	   r
   r&   r/   r   )r   r?   rA   r,   s       r    test_vector_latex_with_functionsrQ      su    sA!.1LE5

qssA!99999

#A!9 0 1 1 1r   c                     d} d}t        t              | k(  sJ t        t              |k(  sJ d} d}t        t              | k(  sJ t        t              |k(  sJ t        t	        g             dk(  sJ t        t	        g             dk(  sJ t        t
              dk(  sJ t        t
              dk(  sJ t        t              dk(  sJ t        t              d	k(  sJ y )
Nz0 2
a  n_x|n_y + b n_y|n_y + c*sin(alpha) n_z|n_yu5    2
a  n_x⊗n_y + b n_y⊗n_y + c⋅sin(α) n_z⊗n_yz7alpha n_x|n_x + sin(omega) n_y|n_z + alpha*beta n_z|n_xu4   α n_x⊗n_x + sin(ω) n_y⊗n_z + α⋅β n_z⊗n_xr+   z- n_x|n_y - n_x|n_zu   - n_x⊗n_y - n_x⊗n_zzn_x|n_y + n_x|n_zu   n_x⊗n_y + n_x⊗n_z)r   r6   r    r/   r   r9   r:   r0   s     r   test_dyadic_pretty_printrS      s    H
I x'''1***HHFIx'''1***$+++6":&#--- 55552";;;;!44443#::::r   c                      d} t        t              | k(  sJ d} t        t              | k(  sJ t        t        g             dk(  sJ y )Nza^{2}\mathbf{\hat{n}_x}\otimes \mathbf{\hat{n}_y} + b\mathbf{\hat{n}_y}\otimes \mathbf{\hat{n}_y} + c \sin{\left(\alpha \right)}\mathbf{\hat{n}_z}\otimes \mathbf{\hat{n}_y}z\alpha\mathbf{\hat{n}_x}\otimes \mathbf{\hat{n}_x} + \sin{\left(\omega \right)}\mathbf{\hat{n}_y}\otimes \mathbf{\hat{n}_z} + \alpha \beta\mathbf{\hat{n}_z}\otimes \mathbf{\hat{n}_x}r+   )r   r6   r/   r   )r1   s    r   test_dyadic_latexrU      sQ    @H
 !9   LH
 !9   &*$$$r   c                      t        t        g             dk(  sJ t        t              dk(  sJ t        t              dk(  sJ t        t              dk(  sJ t        t
              dk(  sJ t        t              dk(  sJ y )Nr+   z5a**2*(N.x|N.y) + b*(N.y|N.y) + c*sin(alpha)*(N.z|N.y)z=alpha*(N.x|N.x) + sin(omega)*(N.y|N.z) + alpha*beta*(N.z|N.x)z-alpha*N.x + asin(omega)*N.y - beta*alpha'*N.zz- (N.x|N.y) - (N.x|N.z)z(N.x|N.y) + (N.x|N.z))r   r   r6   r/   r8   r9   r:   rN   r   r   test_dyadic_strrW      sx    6":#%%%1:PPPP1:XXXX2;IIII2;33333<2222r   c                     ddl m}  t        d      }t        d      }t        d      }t        d      }t        d      }d}| ||      j	                  |      j                   ||       ||       ||      z
        z  } | |      |k(  sJ y )	Nr   )r   r/   JfghzRJ \left(\frac{d}{d x} g{\left(x \right)} - \frac{d}{d x} h{\left(x \right)}\right))sympy.physics.vectorr   r   r   r&   subs)r   r/   rY   rZ   r[   r\   r1   r   s           r   test_vlatexr_      s|    +AAAAAdHQqTYYq\qtQqT!A$Y//D$<8###r   c                  "   t        d      \  } }}t        d      }| |j                  z  ||j                  z  z   ||j                  z  z   }||j                  z  ||j                  z  z   | |j                  z  z   }||z   }d}t        |      |k(  sJ y)z
    Test for proper pretty printing of physics vectors with ADD
    instances in arguments.

    Test is exactly the one suggested in the original bug report by
    @moorepants.
    r   r   z'(a + b) a_x + (b + c) a_y + (a + c) a_zN)r   r	   r/   r6   r7   r   )r;   r<   r=   r   r,   r-   r7   r1   s           r   test_issue_13354ra     s     i GAq!sA	ACC!acc'AG#A	ACC!acc'AG#A	AA<Hx'''r   c                  V   t         j                         t        j                  z  } t	        |       dk(  sJ t        |       dk(  sJ t         j                         j                         t        j                  z  } t        |       dk(  sJ t	        |       dk(  sJ t        |       dk(  sJ t         j                         j                         j                         t        j                  z  } t        |       dk(  sJ t	        |       dk(  sJ t        |       dk(  sJ t         j                         j                         j                         j                         t        j                  z  } t        |       d	k(  sJ t	        |       d
k(  sJ t        |       dk(  sJ t         j                         j                         j                         j                         j                         t        j                  z  } t        |       dk(  sJ d}d}t	        |       |k(  sJ t        |       |k(  sJ y )Nu   ω̇ n_xzomega'(t) n_xz\ddot{\omega}\mathbf{\hat{n}_x}u   ω̈ n_xzomega''(t) n_xz \dddot{\omega}\mathbf{\hat{n}_x}u	   ω⃛ n_xzomega'''(t) n_xz!\ddddot{\omega}\mathbf{\hat{n}_x}u	   ω⃜ n_xzomega''''(t) n_xz.\frac{d^{5}}{d t^{5}} \omega\mathbf{\hat{n}_x}zJ 5            
d             
---(omega) n_x
  5           
dt            u=    5        
d         
───(ω) n_x
  5       
dt        )r?   r&   r   r/   r    r   r   )r,   r1   r2   s      r   test_vector_derivative_printingrc     s   

qssA1+++... 	

acc!A!9::::1+++//// 	

  "QSS(A!9;;;;1,,,0000 	

  "'')ACC/A!9<<<<1,,,1111 	

  "'')..01336A!9IIIIHI 1***x'''r   c                      t        t              dk(  sJ t        t        j                         t        j
                  z        dk(  sJ t        t              dk(  sJ y )Nz+alpha*N.x + sin(omega)*N.y + alpha*beta*N.zz
omega'*N.x)r   r-   r?   r&   r   r/   r   rN   r   r   test_vector_str_printingre   J  sJ    1:FFFF5::<!##%&,666Q<HHHHr   c                      t        t        j                  dz  d      dk(  sJ t        t        j                  dz  d      dk(  sJ y )NrK   FrL   z3.0*N.xTz3.00000000000000*N.x)r   r   r/   rN   r   r   test_vector_str_argumentsrg   P  s=    1339.);;;1339-1GGGGr   c                  X   dd l mc m}  | j                  d      }| j	                  dd      \  }}t        d      }t        |||z   dz  z  |j                  z        dk(  sJ t        ||z   dz  |j                  z        dk(  sJ t        ||z  t        z  |j                  z        d	k(  sJ y )
Nr   r   z
theta, phi   Lr   z>L \left(\dot{\phi} + \dot{\theta}\right)^{2}\mathbf{\hat{a}_x}z<\left(\dot{\phi} + \dot{\theta}\right)^{2}\mathbf{\hat{a}_x}z:\left(\dot{\phi} \dot{\theta}\right)^{a}\mathbf{\hat{a}_x})	sympy.physics.mechanicsphysics	mechanicsr	   r
   r   r   r/   r;   )meA_framethetadphidrj   s        r   test_issue_14041rr   U  s    (($G$$\15LFDA!TF]Q&&wyy01IJ J J4&=1$WYY./GH H H4;"799,-EF F Fr   N)6sympy.core.functionr   sympy.core.symbolr   (sympy.functions.elementary.miscellaneousr   (sympy.functions.elementary.trigonometricr   r   r   r]   r	   r
   r   sympy.physics.vector.printingr   r   r   r   r   r;   r<   r=   rA   r?   betar   r   r/   r6   r7   r,   r-   r&   r8   r.   r9   r:   r   r    r)   r3   rI   rO   rQ   rS   rU   rW   r_   ra   rc   re   rg   rr   rN   r   r   <module>ry      s^   ) % 9 E E G GG G )
1a#$89 ud33FQSSL1qss7QU^acc11	ACCK#e*qss""UT\ACC%77
QSS[4;$$uzz|d':QSS'@@aC!##I1a!##1Q,FaccACCi1acc	?*QU^qssQSSy-II	QSS133Y#e*acc	22UT\QSS133Y5OOSSQSSD133JccQSS133Y=<M0)fC#LV
1 ;:%&3$"((.(bIH
Fr   