
    \h                     <   S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	  S SK
Jr  S SK
Jr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJrJrJrJ r   S SK!J"r"  S SKJr  S SK#J$r$  S SK%J&r&  S SK'r(S SK)J*r*J+r+J,r,J-r-J.r.   " S S\5      r/S r0S SK1J2r2  g)    )Callable)Basic)cacheit)SDummyLambda)Str)symbols)ImmutableDenseMatrix)
MatrixBase)solve)
BaseScalar)Tuple)diff)sqrt)acosatan2cossin)eyesimplify)trigsimpN)OrienterAxisOrienterBodyOrienterSpaceOrienterQuaternionOrienterc                     ^  \ rS rSrSr  S"U 4S jjrS rS r\S 5       r	\S 5       r
S r\S	 5       r\S
 5       rS r\S 5       r\S 5       r\S 5       rS rS rS rS rS rS rS r\S 5       rS r  S#S jr  S$S jr  S$S jr   S$S jr!  S$S jr"  S$S jr#S#S jr$    S%S jr%\R                  \%l        \S  5       r&S!r'U =r($ )&
CoordSys3D   z.
Represents a coordinate system in 3-D space.
c                 r  >^^^ [        U5      n[        R                  R                  n[        R                  R                  n	[        U[         5      (       d  [        S5      eTGb  Uc  Ub  [        S5      e[        T[        [        [        45      (       a6  [        TS   [        5      (       a  TS   nTS   nO[        TS   TS   5      mO[        T[        5      (       a'  [        S[        S9u  pn[        XU4T" XU5      5      mO`[        T[         5      (       a  [!        T5      mO?[        T[         [        45      (       a  O#[        SR#                  [%        T5      5      5      eUc  ['        [)        S	5      5      nO0[        U[        5      (       d  [        S
5      eUR+                  5       nUb  [        U[,        5      (       d  [        S5      eUc  UR.                  nON[        XH5      (       d  [        S5      eUR0                   H#  n[        U[2        5      (       d  M  [        S5      e   UR4                  R7                  US-   U5      nOUR.                  nU	" US-   5      nTc  [        XT5      m[        T[        5      (       aL  [,        R9                  TS   TS   U5      nTu  mmTR:                  m[,        R=                  S5      nUU4S jnGO![        T[         5      (       a  TR>                  n[,        RA                  U5      nUbL  URC                  5       [D        RF                  [D        RF                  [D        RF                  4:w  a  [        S5      e[,        R=                  U5      n[,        RI                  U5      nOq[        T[        5      (       a?  [,        RK                  T5      (       d  [        S5      eTn[,        RM                  U5      nSnOU4S jn[,        R=                  T5      nSnUcb  [        T[        5      (       a  / SQnOH[        T[         5      (       a/  TR>                  S:X  a  / SQnOTR>                  S:X  a  / SQnO	/ SQnO/ SQnUc  / SQnUb  [N        TU ]  U [!        U5      TU5      nO[N        TU ]  U [!        U5      T5      nUUl)        [U        SU5        [        U5      nU Vs/ s H  nSU< SU< S3PM     nnU Vs/ s H  o< SU< 3PM     nnUUl+        [Y        SUUS   US   5      n[Y        SUUS   US   5      n[Y        S UUS    US    5      nUUU4Ul-        [U        S!U5        [        U5      nU Vs/ s H  nS"U< SU< S3PM     nnU Vs/ s H  o< SU< 3PM     nnUUl.        UUl+        [3        SUUS   US   5      n
[3        SUUS   US   5      n[3        S UUS    US    5      nXU4Ul/        TUl0        UUl1        U" XU5      Ul2        UUl3        [i        UUS   U
5        [i        UUS   U5        [i        UUS    U5        [i        UUS   U5        [i        UUS   U5        [i        UUS    U5        UUl5        URj                  b  URj                  Rl                  Ul6        OUUl6        UUl7        UUl8        U$ s  snf s  snf s  snf s  snf )#a  
The orientation/location parameters are necessary if this system
is being defined at a certain orientation or location wrt another.

Parameters
==========

name : str
    The name of the new CoordSys3D instance.

transformation : Lambda, Tuple, str
    Transformation defined by transformation equations or chosen
    from predefined ones.

location : Vector
    The position vector of the new system's origin wrt the parent
    instance.

rotation_matrix : SymPy ImmutableMatrix
    The rotation matrix of the new coordinate system with respect
    to the parent. In other words, the output of
    new_system.rotation_matrix(parent).

parent : CoordSys3D
    The coordinate system wrt which the orientation/location
    (or both) is being defined.

vector_names, variable_names : iterable(optional)
    Iterables of 3 strings each, with custom names for base
    vectors and base scalars of the new system respectively.
    Used for simple str printing.

zname should be a stringNz?specify either `transformation` or `location`/`rotation_matrix`r      zx1 x2 x3clsztransformation: wrong type {}   z5rotation_matrix should be an ImmutableMatrix instancez"parent should be a CoordSys3D/Nonezlocation should be a Vectorz'location should not contain BaseScalarsz.origin	cartesianc                 f   > TR                  5       [        U TS   -
  UTS   -
  UTS   -
  /5      -  $ )Nr   r#      )invMatrix)xyzlrs      Q/var/www/auris/envauris/lib/python3.13/site-packages/sympy/vector/coordsysrect.py<lambda>$CoordSys3D.__new__.<locals>.<lambda>   s9    QUUWV1Q41Q41Q4(6* .*    z=Parent for pre-defined coordinate system should be Cartesian.zHThe transformation equation does not create orthogonal coordinate systemc                    > T" XU5      $ N )r,   r-   r.   transformations      r1   r2   r3      s    N14Kr4   )x1x2x3	sphericalr0   thetaphicylindrical)r0   r>   r.   r,   r-   r.   )ijkvector_namesz\mathbf{\hat{z}_{z}}_r)   variable_namesz	\mathbf{{)9strsympyvectorVectorPoint
isinstance	TypeError
ValueErrorr   tuplelistr   r   r   r
   r   r	   formattyper   r   as_immutabler    zerofree_symbolsr   origin
locate_new!_compose_rotation_and_translation_projections_get_lame_coeffname_get_transformation_lambdaslame_coefficientsr   One_set_inv_trans_equations_check_orthogonality_calculate_lame_coeffsuper__new___name_check_strings_vector_names
BaseVector_base_vectors_variable_names_base_scalars_transformation_transformation_lambda_lame_coefficients"_transformation_from_parent_lambdasetattr_parent_root_parent_rotation_matrix_origin)r%   r\   r8   parentlocationrotation_matrixrE   rG   rK   rL   r9   r:   r;   r,   rW   lambda_transformationlambda_lamelambda_inversetrnameobjlatex_vectspretty_vectsv1v2v3latex_scalarspretty_scalarsr/   r0   	__class__s     `                        @@r1   rd   CoordSys3D.__new__   s   H 4y$$""$$$566%$/*E  "@ A A.5%*>??nQ/<<&4Q&7O-a0H%+N1,=,:1,=&?NNH55$ZU;
!'(6rr(B"DNC00!$^!4NS&M:: !006tN7K0LN N
 "23q6:Ooz:: !2 3 3-::<O fj11 !2 3 3!;;!(33#$ABB "..A!!Z00( *8 9 9 / ]]--dY.>.68F {{H4)+,F!"?=Nne,,$.$P$Pq!q!%!
 "DAqA$44[AK*N,,#((F$.$J$J6$R!!++-!%%1FF$ &? @ @$44V<K'@@HN//22>BB  "G H H$2!$::;PQK!N$K!$44^DK!N!.&11!3NC00!&&+5%:N#((M9%8N%4N!0*L '/SY8C '/SY0C	 	~|4L) ,. ,1 67= , 	 .5AB\1d+\B(3QQ@3QQ@3QQ@RL 	'6n-,., 45d;, 	 .7EF~!Q-~F,(3q 1=3CD3q 1=3CD3q 1=3CDRL,%:"!,RR!81?.^A&+^A&+^A&+\!_b)\!_b)\!_b) ;;"))CICI&5# 
k.B.Fs   Z%Z*Z/4Z4c                     U R                   $ r6   )re   )selfprinters     r1   	_sympystrCoordSys3D._sympystr   s    zzr4   c                 4    [        U R                  5       5      $ r6   )iterbase_vectorsr   s    r1   __iter__CoordSys3D.__iter__  s    D%%'((r4   c                 `   [        S[        S9u  pnU " XU5      n [        [        U S   U5      [        U S   U5      [        U S   U5      /5      n[        [        U S   U5      [        U S   U5      [        U S   U5      /5      n[        [        U S   U5      [        U S   U5      [        U S   U5      /5      n[	        S XEU4 5       5      (       a  g[        UR                  U5      5      S:X  a=  [        UR                  U5      5      S:X  a  [        UR                  U5      5      S:X  a  gg)	z
Helper method for _connect_to_cartesian. It checks if
set of transformation equations create orthogonal curvilinear
coordinate system

Parameters
==========

equations : Lambda
    Lambda of transformation equations


x1, x2, x3r$   r   r#   r)   c              3   \   #    U  H"  n[        US    US   -   US   -   5      S :H  v   M$     g7f)r   r#   r)   Nr   ).0rB   s     r1   	<genexpr>2CoordSys3D._check_orthogonality.<locals>.<genexpr>  s/     G,Qx!qtad*+q0,s   *,FT)r
   r   r+   r   anyr   dot)	equationsr9   r:   r;   r   r   r   s          r1   ra   CoordSys3D._check_orthogonality  s-    \u5
bb)	T)A,+)A,+T)A,-CE F T)A,+)A,+T)A,-CE F T)A,+)A,+T)A,-CE F G22,GGGr
#q(XbffRj-AQ-FRVVBZ(A-r4   c                 N    U S:X  a  S $ U S:X  a  S $ U S:X  a  S $ [        S5      e)z
Store information about inverse transformation equations for
pre-defined coordinate systems.

Parameters
==========

curv_coord_name : str
    Name of coordinate system

r'   c                 
    XU4$ r6   r7   rA   s      r1   r2   5CoordSys3D._set_inv_trans_equations.<locals>.<lambda>5  s    A!9r4   r<   c           	          [        U S-  US-  -   US-  -   5      [        U[        U S-  US-  -   US-  -   5      -  5      [        X5      4$ Nr)   )r   r   r   rA   s      r1   r2   r   8  sR    QTAqD[1a4'(QtAqD1a4K!Q$.//0a$r4   r@   c                 B    [        U S-  US-  -   5      [        X5      U4$ r   )r   r   rA   s      r1   r2   r   >  s%    QTAqD[!a$r4   <Wrong set of parameters.Type of coordinate system is defined)rO   curv_coord_names    r1   r`   #CoordSys3D._set_inv_trans_equations'  sO     k),,k) 
 m+ 
  @ A 	Ar4   c                    ^^^^ [        S[        SS9u  pn[        S[        S9u  mmmU R                  XU5      n[        US   T-
  US   T-
  US   T-
  /XU4SS	9S   mTU   TU   TU   4mUUUU4S
 jU l        g)z}
Helper method for set_coordinate_type. It calculates inverse
transformation equations for given transformations equations.

r   T)r%   realszx, y, zr$   r   r#   r)   )dictc                 >   >^ ^^ [        UU UUUU4S jT 5       5      $ )Nc              3   v   >#    U  H.  oR                  [        [        TTT4TTT45      5      5      v   M0     g 7fr6   )subsrQ   zip)r   rB   r,   r9   r:   r;   r-   r.   s     r1   r   NCoordSys3D._calculate_inv_trans_equations.<locals>.<lambda>.<locals>.<genexpr>V  s6     $`Y_TUVVDaAYR1M,N%O%OY_s   69)rP   )r9   r:   r;   solvedr,   r-   r.   s   ```r1   r2   ;CoordSys3D._calculate_inv_trans_equations.<locals>.<lambda>V  s    u$`$`Y_$``r4   N)r
   r   rl   r   ro   )	r   r9   r:   r;   r   r   r,   r-   r.   s	        @@@@r1   _calculate_inv_trans_equations)CoordSys3D._calculate_inv_trans_equationsF  s     \uDA
)/1a((4		!q(!!q(!!q(*,.B<dDDEG VBZ3` 	/r4   c                     [        U [        5      (       a&  U S:X  a  S $ U S:X  a  S $ U S:X  a  S $ [        S5      e[        R	                  U 5      $ )z
Store information about Lame coefficients for pre-defined
coordinate systems.

Parameters
==========

curv_coord_name : str
    Name of coordinate system

r'   c                 `    [         R                  [         R                  [         R                  4$ r6   r   r_   rA   s      r1   r2   ,CoordSys3D._get_lame_coeff.<locals>.<lambda>g  s    quuaee'<r4   r<   c                 >    [         R                  X [        U5      -  4$ r6   )r   r_   r   r=   s      r1   r2   r   i  s    aeeQ#e*-Er4   r@   c                 D    [         R                  U [         R                  4$ r6   r   r0   r>   hs      r1   r2   r   k  s    AEE1aee+<r4   zAWrong set of parameters. Type of coordinate system is not defined)rM   rH   rO   r    _calculate_lame_coefficientsr   s    r1   r[   CoordSys3D._get_lame_coeffX  sa     os+++-<<+-EE-/<< I J J66GGr4   c                    ^  U 4S j$ )z
It calculates Lame coefficients
for given transformations equations.

Parameters
==========

equations : Lambda
    Lambda of transformation equations.

c                   > [        [        T" XU5      S   U 5      S-  [        T" XU5      S   U 5      S-  -   [        T" XU5      S   U 5      S-  -   5      [        [        T" XU5      S   U5      S-  [        T" XU5      S   U5      S-  -   [        T" XU5      S   U5      S-  -   5      [        [        T" XU5      S   U5      S-  [        T" XU5      S   U5      S-  -   [        T" XU5      S   U5      S-  -   5      4$ )Nr   r)   r#   )r   r   )r9   r:   r;   r   s      r1   r2   2CoordSys3D._calculate_lame_coeff.<locals>.<lambda>}  s;   tIbb$9!$<bA1D#Ibb$9!$<bA1D E#Ibb$9!$<bA1D E F tIbb$9!$<bA1D#Ibb$9!$<bA1D E#Ibb$9!$<bA1D E F tIbb$9!$<bA1D#Ibb$9!$<bA1D E#Ibb$9!$<bA1D E F
#r4   r7   )r   s   `r1   rb    CoordSys3D._calculate_lame_coeffp  s    
 
	r4   c                 2    [        U R                  S-  5      $ )z"
Returns inverse rotation matrix.
)r   rs   r   s    r1   _inverse_rotation_matrix#CoordSys3D._inverse_rotation_matrix  s     44b899r4   c                 z    [        U [        5      (       a&  U S:X  a  S $ U S:X  a  S $ U S:X  a  S $ [        S5      eg)	z
Store information about transformation equations for pre-defined
coordinate systems.

Parameters
==========

curv_coord_name : str
    Name of coordinate system

r'   c                 
    XU4$ r6   r7   rA   s      r1   r2   8CoordSys3D._get_transformation_lambdas.<locals>.<lambda>  s    ayr4   r<   c                     U [        U5      -  [        U5      -  U [        U5      -  [        U5      -  U [        U5      -  4$ r6   )r   r   r=   s      r1   r2   r     s:    c%jLS)c%jLS)c%jL.r4   r@   c                 <    U [        U5      -  U [        U5      -  U4$ r6   )r   r   r   s      r1   r2   r     s     c%jLc%jL,r4   r   N)rM   rH   rO   r   s    r1   r]   &CoordSys3D._get_transformation_lambdas  sa     os+++-00+- 
 -/ 
  D E E ,r4   c                 0    [        U[        U5      -  5      $ )z
Returns the transformation equations obtained from rotation matrix.

Parameters
==========

matrix : Matrix
    Rotation matrix

equations : tuple
    Transformation equations

)rP   r+   )r%   matrixr   s      r1   _rotation_trans_equations$CoordSys3D._rotation_trans_equations  s     VfY//00r4   c                     U R                   $ r6   )rt   r   s    r1   rW   CoordSys3D.origin  s    ||r4   c                     U R                   $ r6   )ri   r   s    r1   r   CoordSys3D.base_vectors      !!!r4   c                     U R                   $ r6   )rk   r   s    r1   base_scalarsCoordSys3D.base_scalars  r   r4   c                     U R                   $ r6   )rn   r   s    r1   r^   CoordSys3D.lame_coefficients  s    &&&r4   c                 <    U R                   " U R                  5       6 $ r6   )rm   r   r   s    r1   transformation_to_parent#CoordSys3D.transformation_to_parent  s    **D,=,=,?@@r4   c                     U R                   c  [        S5      eU R                  " U R                   R                  5       6 $ )NzHno parent coordinate system, use `transformation_from_parent_function()`)rq   rO   ro   r   r   s    r1   transformation_from_parent%CoordSys3D.transformation_from_parent  sD    << G H H66!\\668: 	:r4   c                     U R                   $ r6   ro   r   s    r1   #transformation_from_parent_function.CoordSys3D.transformation_from_parent_function  s    666r4   c                    SSK Jn  [        U[        5      (       d  [	        [        U5      S-   5      eX:X  a  [        S5      $ XR                  :X  a  U R                  $ UR                  U :X  a  UR                  R                  $ U" X5      u  p4[        S5      n[        U5       H  nXTU   R                  -  nM     [        US-   [        U5      5       H  nXTU   R                  R                  -  nM      U$ )a  
Returns the direction cosine matrix(DCM), also known as the
'rotation matrix' of this coordinate system with respect to
another system.

If v_a is a vector defined in system 'A' (in matrix format)
and v_b is the same vector defined in system 'B', then
v_a = A.rotation_matrix(B) * v_b.

A SymPy Matrix is returned.

Parameters
==========

other : CoordSys3D
    The system which the DCM is generated to.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> from sympy import symbols
>>> q1 = symbols('q1')
>>> N = CoordSys3D('N')
>>> A = N.orient_new_axis('A', q1, N.i)
>>> N.rotation_matrix(A)
Matrix([
[1,       0,        0],
[0, cos(q1), -sin(q1)],
[0, sin(q1),  cos(q1)]])

r   )_pathz is not a CoordSys3Dr&   r#   )sympy.vector.functionsr   rM   r    rN   rH   r   rq   rs   Trangelen)r   otherr   	rootindexpathresultrB   s          r1   rw   CoordSys3D.rotation_matrix  s    B 	1%,,CJ23 4 4 =q6Mll"///]]d"00222,	Qy!A1g555F "y1}c$i0A1g55777F 1r4   c                 8    U R                   R                  U5      $ )a  
Returns the position vector of the origin of this coordinate
system with respect to another Point/CoordSys3D.

Parameters
==========

other : Point/CoordSys3D
    If other is a Point, the position of this system's origin
    wrt it is returned. If its an instance of CoordSyRect,
    the position wrt its origin is returned.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> N = CoordSys3D('N')
>>> N1 = N.locate_new('N1', 10 * N.i)
>>> N.position_wrt(N1)
(-10)*N.i

)rW   position_wrt)r   r   s     r1   r   CoordSys3D.position_wrt  s    0 {{''..r4   c           	      ~   [        U R                  U5      R                  U5      5      n[        UR	                  5       5       VVs/ s H  u  p4XBU   -
  PM     nnnU R                  U5      [        U5      -  n[        U R	                  5       5       VVs0 s H  u  p4U[        Xc   5      _M     snn$ s  snnf s  snnf )a  
Returns a dictionary which expresses the coordinate variables
(base scalars) of this frame in terms of the variables of
otherframe.

Parameters
==========

otherframe : CoordSys3D
    The other system to map the variables to.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> from sympy import Symbol
>>> A = CoordSys3D('A')
>>> q = Symbol('q')
>>> B = A.orient_new_axis('B', q, A.k)
>>> A.scalar_map(B)
{A.x: B.x*cos(q) - B.y*sin(q), A.y: B.x*sin(q) + B.y*cos(q), A.z: B.z}

)rP   r   	to_matrix	enumerater   rw   r+   r   )r   r   origin_coordsrB   r,   relocated_scalarsvars_matrixs          r1   
scalar_mapCoordSys3D.scalar_map(  s    2 d//6@@GH)253E3E3G)HJ)H q!11)H 	 J ++E2/01 &d&7&7&9:<:DA 8KN++:< 	<J
<s   B3B9c                 V    Uc  U R                   nUc  U R                  n[        XUUU S9$ )a  
Returns a CoordSys3D with its origin located at the given
position wrt this coordinate system's origin.

Parameters
==========

name : str
    The name of the new CoordSys3D instance.

position : Vector
    The position vector of the new system's origin wrt this
    one.

vector_names, variable_names : iterable(optional)
    Iterables of 3 strings each, with custom names for base
    vectors and base scalars of the new system respectively.
    Used for simple str printing.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> A = CoordSys3D('A')
>>> B = A.locate_new('B', 10 * A.i)
>>> B.origin.position_wrt(A.origin)
10*A.i

)rv   rE   rG   ru   )rj   rg   r    )r   r\   positionrE   rG   s        r1   rX   CoordSys3D.locate_newJ  s>    > !!11N--L$'3)7!%' 	'r4   c           	         Uc  U R                   nUc  U R                  n[        U[        5      (       aC  [        U[        5      (       a  UR                  U 5      nOUR                  5       n[        U5      nOY[        [        S5      5      nU H?  n[        U[        5      (       a  XgR                  U 5      -  nM-  XgR                  5       -  nMA     [        XUUUU S9$ )a  
Creates a new CoordSys3D oriented in the user-specified way
with respect to this system.

Please refer to the documentation of the orienter classes
for more information about the orientation procedure.

Parameters
==========

name : str
    The name of the new CoordSys3D instance.

orienters : iterable/Orienter
    An Orienter or an iterable of Orienters for orienting the
    new coordinate system.
    If an Orienter is provided, it is applied to get the new
    system.
    If an iterable is provided, the orienters will be applied
    in the order in which they appear in the iterable.

location : Vector(optional)
    The location of the new coordinate system's origin wrt this
    system's origin. If not specified, the origins are taken to
    be coincident.

vector_names, variable_names : iterable(optional)
    Iterables of 3 strings each, with custom names for base
    vectors and base scalars of the new system respectively.
    Used for simple str printing.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> from sympy import symbols
>>> q0, q1, q2, q3 = symbols('q0 q1 q2 q3')
>>> N = CoordSys3D('N')

Using an AxisOrienter

>>> from sympy.vector import AxisOrienter
>>> axis_orienter = AxisOrienter(q1, N.i + 2 * N.j)
>>> A = N.orient_new('A', (axis_orienter, ))

Using a BodyOrienter

>>> from sympy.vector import BodyOrienter
>>> body_orienter = BodyOrienter(q1, q2, q3, '123')
>>> B = N.orient_new('B', (body_orienter, ))

Using a SpaceOrienter

>>> from sympy.vector import SpaceOrienter
>>> space_orienter = SpaceOrienter(q1, q2, q3, '312')
>>> C = N.orient_new('C', (space_orienter, ))

Using a QuaternionOrienter

>>> from sympy.vector import QuaternionOrienter
>>> q_orienter = QuaternionOrienter(q0, q1, q2, q3)
>>> D = N.orient_new('D', (q_orienter, ))
r&   )rw   rE   rG   rv   ru   )
rj   rg   rM   r   r   rw   r   r+   r   r    )r   r\   	orientersrv   rE   rG   final_matrixorienters           r1   
orient_newCoordSys3D.orient_news  s    B !!11N--Li**)\22(88>(88: $L1L!#a&>L%h55 $<$<T$BBL $<$<$>>L	 & $'3)7#+!%	' 	'r4   c                 x    Uc  U R                   nUc  U R                  n[        X#5      nU R                  XUUUS9$ )a  
Axis rotation is a rotation about an arbitrary axis by
some angle. The angle is supplied as a SymPy expr scalar, and
the axis is supplied as a Vector.

Parameters
==========

name : string
    The name of the new coordinate system

angle : Expr
    The angle by which the new system is to be rotated

axis : Vector
    The axis around which the rotation has to be performed

location : Vector(optional)
    The location of the new coordinate system's origin wrt this
    system's origin. If not specified, the origins are taken to
    be coincident.

vector_names, variable_names : iterable(optional)
    Iterables of 3 strings each, with custom names for base
    vectors and base scalars of the new system respectively.
    Used for simple str printing.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> from sympy import symbols
>>> q1 = symbols('q1')
>>> N = CoordSys3D('N')
>>> B = N.orient_new_axis('B', q1, N.i + 2 * N.j)

rv   rE   rG   )rj   rg   r   r   )r   r\   angleaxisrv   rE   rG   r   s           r1   orient_new_axisCoordSys3D.orient_new_axis  sR    N !!11N--L,t(0,8.<  > 	>r4   c	                 >    [        X#XE5      n	U R                  XUUUS9$ )a  
Body orientation takes this coordinate system through three
successive simple rotations.

Body fixed rotations include both Euler Angles and
Tait-Bryan Angles, see https://en.wikipedia.org/wiki/Euler_angles.

Parameters
==========

name : string
    The name of the new coordinate system

angle1, angle2, angle3 : Expr
    Three successive angles to rotate the coordinate system by

rotation_order : string
    String defining the order of axes for rotation

location : Vector(optional)
    The location of the new coordinate system's origin wrt this
    system's origin. If not specified, the origins are taken to
    be coincident.

vector_names, variable_names : iterable(optional)
    Iterables of 3 strings each, with custom names for base
    vectors and base scalars of the new system respectively.
    Used for simple str printing.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> from sympy import symbols
>>> q1, q2, q3 = symbols('q1 q2 q3')
>>> N = CoordSys3D('N')

A 'Body' fixed rotation is described by three angles and
three body-fixed rotation axes. To orient a coordinate system D
with respect to N, each sequential rotation is always about
the orthogonal unit vectors fixed to D. For example, a '123'
rotation will specify rotations about N.i, then D.j, then
D.k. (Initially, D.i is same as N.i)
Therefore,

>>> D = N.orient_new_body('D', q1, q2, q3, '123')

is same as

>>> D = N.orient_new_axis('D', q1, N.i)
>>> D = D.orient_new_axis('D', q2, D.j)
>>> D = D.orient_new_axis('D', q3, D.k)

Acceptable rotation orders are of length 3, expressed in XYZ or
123, and cannot have a rotation about about an axis twice in a row.

>>> B = N.orient_new_body('B', q1, q2, q3, '123')
>>> B = N.orient_new_body('B', q1, q2, 0, 'ZXZ')
>>> B = N.orient_new_body('B', 0, 0, 0, 'XYX')

r  )r   r   
r   r\   angle1angle2angle3rotation_orderrv   rE   rG   r   s
             r1   orient_new_bodyCoordSys3D.orient_new_body  s2    B  Gt(0,8.<  > 	>r4   c	                 >    [        X#XE5      n	U R                  XUUUS9$ )a[  
Space rotation is similar to Body rotation, but the rotations
are applied in the opposite order.

Parameters
==========

name : string
    The name of the new coordinate system

angle1, angle2, angle3 : Expr
    Three successive angles to rotate the coordinate system by

rotation_order : string
    String defining the order of axes for rotation

location : Vector(optional)
    The location of the new coordinate system's origin wrt this
    system's origin. If not specified, the origins are taken to
    be coincident.

vector_names, variable_names : iterable(optional)
    Iterables of 3 strings each, with custom names for base
    vectors and base scalars of the new system respectively.
    Used for simple str printing.

See Also
========

CoordSys3D.orient_new_body : method to orient via Euler
    angles

Examples
========

>>> from sympy.vector import CoordSys3D
>>> from sympy import symbols
>>> q1, q2, q3 = symbols('q1 q2 q3')
>>> N = CoordSys3D('N')

To orient a coordinate system D with respect to N, each
sequential rotation is always about N's orthogonal unit vectors.
For example, a '123' rotation will specify rotations about
N.i, then N.j, then N.k.
Therefore,

>>> D = N.orient_new_space('D', q1, q2, q3, '312')

is same as

>>> B = N.orient_new_axis('B', q1, N.i)
>>> C = B.orient_new_axis('C', q2, N.j)
>>> D = C.orient_new_axis('D', q3, N.k)

r  )r   r   r  s
             r1   orient_new_spaceCoordSys3D.orient_new_spaceK  s2    v !Ht(0,8.<  > 	>r4   c	                 >    [        X#XE5      n	U R                  XUUUS9$ )aN  
Quaternion orientation orients the new CoordSys3D with
Quaternions, defined as a finite rotation about lambda, a unit
vector, by some amount theta.

This orientation is described by four parameters:

q0 = cos(theta/2)

q1 = lambda_x sin(theta/2)

q2 = lambda_y sin(theta/2)

q3 = lambda_z sin(theta/2)

Quaternion does not take in a rotation order.

Parameters
==========

name : string
    The name of the new coordinate system

q0, q1, q2, q3 : Expr
    The quaternions to rotate the coordinate system by

location : Vector(optional)
    The location of the new coordinate system's origin wrt this
    system's origin. If not specified, the origins are taken to
    be coincident.

vector_names, variable_names : iterable(optional)
    Iterables of 3 strings each, with custom names for base
    vectors and base scalars of the new system respectively.
    Used for simple str printing.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> from sympy import symbols
>>> q0, q1, q2, q3 = symbols('q0 q1 q2 q3')
>>> N = CoordSys3D('N')
>>> B = N.orient_new_quaternion('B', q0, q1, q2, q3)

r  )r   r   )
r   r\   q0q1q2q3rv   rE   rG   r   s
             r1   orient_new_quaternion CoordSys3D.orient_new_quaternion  s2    b &bb5t(0,8.<  > 	>r4   c                     [        XUX4S9$ )aZ  
Returns a CoordSys3D which is connected to self by transformation.

Parameters
==========

name : str
    The name of the new CoordSys3D instance.

transformation : Lambda, Tuple, str
    Transformation defined by transformation equations or chosen
    from predefined ones.

vector_names, variable_names : iterable(optional)
    Iterables of 3 strings each, with custom names for base
    vectors and base scalars of the new system respectively.
    Used for simple str printing.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> a = CoordSys3D('a')
>>> b = a.create_new('b', transformation='spherical')
>>> b.transformation_to_parent()
(b.r*sin(b.theta)*cos(b.phi), b.r*sin(b.phi)*sin(b.theta), b.r*cos(b.theta))
>>> b.transformation_from_parent()
(sqrt(a.x**2 + a.y**2 + a.z**2), acos(a.z/sqrt(a.x**2 + a.y**2 + a.z**2)), atan2(a.y, a.x))

)ru   r8   rG   rE   )r    )r   r\   r8   rG   rE   s        r1   
create_newCoordSys3D.create_new  s    > $N)7T 	Tr4   c                     g r6   r7   )r   r\   rv   rw   ru   rE   rG   r}   r~   r   r   r8   s               r1   __init__CoordSys3D.__init__  s    
 	r4   c                    ^ ^^^^^ U 4S jmUc  T$ UR                  5        Vs/ s H  o1R                  U5      PM     snu  mmmUUU4S jmUU4S j$ s  snf )Nc                 4   > [         R                  TXU45      $ r6   )r    r   )r,   r-   r.   rots      r1   r2   >CoordSys3D._compose_rotation_and_translation.<locals>.<lambda>  s    J@@qQiPr4   c                     > U T-   UT-   UT-   4$ r6   r7   )r,   r-   r.   dxdydzs      r1   r2   r!    s    FFF
r4   c                    > T" T" XU5      6 $ r6   r7   )r,   r-   r.   r0   ts      r1   r2   r!    s    q!A!*~r4   )r   r   )	r   translationru   rB   r#  r$  r%  r0   r'  s	   `   @@@@@r1   rY   ,CoordSys3D._compose_rotation_and_translation  sS    P>H282E2E2GH2GQooa(2GH
B

 .- Is   Ar   )NNNNNN)NN)NNN)
NNNNNNNNNN))__name__
__module____qualname____firstlineno____doc__rd   r   r   staticmethodra   r`   r   r[   rb   r   r]   classmethodr   propertyrW   r   r   r^   r   r   r   rw   r   r   r   rX   r   r  r  r  r  r  r  rY   __static_attributes____classcell__)r   s   @r1   r    r       s    GKHL^@)    D A A<a$ H H.  0: E E< 1 1   ""'A:73j / /2 <D 7;"&''R 4859]'~ ;?:>0>f 26:>E>P 37;??>B DH@D5>n TD =A@DDH59 H. .r4   r    c                     U S-   n[        U5      S:w  a  [        U5      eU H#  n[        U[        5      (       a  M  [	        U5      e   g )Nz& must be an iterable of 3 string-typesr&   )r   rO   rM   rH   rN   )arg_nameargerrorstrss       r1   rf   rf     sE    BBH
3x1}""!S!!H%% r4   )rh   )3collections.abcr   sympy.core.basicr   sympy.core.cacher   
sympy.corer   r   r   sympy.core.symbolr	   r
   sympy.matrices.immutabler   r+   sympy.matrices.matrixbaser   sympy.solversr   sympy.vector.scalarr   sympy.core.containersr   sympy.core.functionr   (sympy.functions.elementary.miscellaneousr   (sympy.functions.elementary.trigonometricr   r   r   r   sympy.matrices.denser   sympy.simplify.simplifyr   sympy.simplify.trigsimpr   sympy.vectorrI   sympy.vector.orientersr   r   r   r   r   r    rf   sympy.vector.vectorrh   r7   r4   r1   <module>rL     si    $ " $ ' ' ! % C 0  * ' $ 9 L L $ 9 , , G Ga. a.H& +r4   