o
    oh                     @   s8  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 d dl
mZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZmZmZm Z  d dl!m"Z" d dlmZ d dl#m$Z$ d dl%m&Z& d dl'Z(d dl)m*Z*m+Z+m,Z,m-Z-m.Z. G dd deZ/dd Z0d dl1m2Z2 dS )    )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                       sj  e Zd ZdZ		d? fdd	Zdd Zdd Zed	d
 Zedd Z	dd Z
edd Zedd Zdd Zedd Ze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ed)d* Zd+d, Z		d@d-d.Z		dAd/d0Z		dAd1d2Z		dAd3d4Z 		dAd5d6Z!		dAd7d8Z"d@d9d:Z#				dBd;d<Z$eje$_ed=d> Z%  Z&S )C
CoordSys3Dz6
    Represents a coordinate system in 3-D space.
    Nc                    s8  t tjj}tjj}	tt stddur}|dus!|dur%tdttt	t
frGtd tr=d }d }n@td d n6ttrbtdtd\}
}}t|
||f|
||ntt rltntttfrtn	tdt|du rttd	}nt|tstd
| }|durt|tstd|du r|j}nt||std|jD ]}t|trtdq|jd |}n	|j}|	d }du rt||ttrtd d |}\  j td} fdd}nVttr2j}t |}|dur'|! t"j#t"j#t"j#fkr'tdt|}t$|}n'ttrLt%sBtd}t&|}d}nfdd}t}d}|du rttrig d}n%ttrjdkrzg d}njdkrg d}n	g d}ng d}|du rg d}|durt' (| t|}n
t' (| t}|_)t*d| t
|}fdd|D }fdd|D }||_+t,d||d |d }t,d||d |d }t,d ||d  |d  }|||f|_-t*d!| t
|}fd"d|D }fd#d|D }||_.||_+td||d |d }
td||d |d }td ||d  |d  }|
||f|_/|_0||_1||
|||_2||_3t4||d |
 t4||d | t4||d  | t4||d | t4||d | t4||d  | ||_5|j5dur|j5j6|_6n||_6||_7||_8|S )$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                    s.     t|  d  | d  | d  g S )Nr   r       )invMatrixxyz)lr m/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/vector/coordsysrect.py<lambda>   s     z$CoordSys3D.__new__.<locals>.<lambda>z=Parent for pre-defined coordinate system should be Cartesian.zHThe transformation equation does not create orthogonal coordinate systemc                    s    | ||S Nr.   r(   )transformationr.   r/   r0      s    x1x2x3	sphericalr-   thetaphicylindrical)r-   r9   r+   r(   )ijkvector_namesc                       g | ]}d | f qS )z\mathbf{\hat{%s}_{%s}}r.   .0r)   namer.   r/   
<listcomp>       z&CoordSys3D.__new__.<locals>.<listcomp>c                    r@   z%s_%sr.   rA   rC   r.   r/   rE          r%   variable_namesc                    r@   )z\mathbf{{%s}_{%s}}r.   rA   rC   r.   r/   rE      rF   c                    r@   rG   r.   rA   rC   r.   r/   rE      rH   )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_coeffrD   _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"   rD   r2   parentlocationrotation_matrixr?   rI   rM   rN   r4   r5   r6   r)   rY   lambda_transformationlambda_lamelambda_inversetrnameobjlatex_vectspretty_vectsv1v2v3latex_scalarspretty_scalars	__class__)r,   rD   r-   r2   r/   re      s  $































zCoordSys3D.__new__c                 C      | j S r1   )rf   )selfprinterr.   r.   r/   	_sympystr      zCoordSys3D._sympystrc                 C   s   t |  S r1   )iterbase_vectorsr   r.   r.   r/   __iter__  s   zCoordSys3D.__iter__c                 C   s   t dtd\}}}| |||} tt| d |t| d |t| d |g}tt| d |t| d |t| d |g}tt| d |t| d |t| d |g}tdd |||fD r_dS t||dkr|t||dkr|t||dkr|d	S dS )
a  
        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                 s   s0    | ]}t |d  |d  |d  d kV  qdS )r   r    r%   Nr   rB   r<   r.   r.   r/   	<genexpr>     . z2CoordSys3D._check_orthogonality.<locals>.<genexpr>FT)r	   r   r'   r   anyr   dot)	equationsr4   r5   r6   r   r   r   r.   r.   r/   rb     s"   $zCoordSys3D._check_orthogonalityc                 C   s8   | dkrdd S | dkrdd S | dkrdd S t d)	z
        Store information about inverse transformation equations for
        pre-defined coordinate systems.

        Parameters
        ==========

        curv_coord_name : str
            Name of coordinate system

        r$   c                 S   
   | ||fS r1   r.   r(   r.   r.   r/   r0   5     
 z5CoordSys3D._set_inv_trans_equations.<locals>.<lambda>r7   c                 S   sH   t | d |d  |d  t|t | d |d  |d   t|| fS Nr%   )r   r   r   r(   r.   r.   r/   r0   8  s   "r;   c                 S   s    t | d |d  t|| |fS r   )r   r   r(   r.   r.   r/   r0   >  s   <Wrong set of parameters.Type of coordinate system is defined)rQ   curv_coord_namer.   r.   r/   ra   '  s   z#CoordSys3D._set_inv_trans_equationsc                    s   t dtdd\}}}t dtd\| |||}t|d  |d  |d  g|||fdd	d   |  |  | f  fd
d| _dS )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                    s    t  fddD S )Nc              	   3   s0    | ]}| tt ffV  qd S r1   )subsrS   zipr   )r)   r4   r5   r6   r*   r+   r.   r/   r   V  r   zNCoordSys3D._calculate_inv_trans_equations.<locals>.<lambda>.<locals>.<genexpr>)rR   r3   solvedr)   r*   r+   r3   r/   r0   V  s     z;CoordSys3D._calculate_inv_trans_equations.<locals>.<lambda>N)r	   r   rm   r   rp   )r   r4   r5   r6   r   r.   r   r/   _calculate_inv_trans_equationsF  s   


z)CoordSys3D._calculate_inv_trans_equationsc                 C   sL   t | tr!| dkrdd S | dkrdd S | dkrdd S tdt| S )	z
        Store information about Lame coefficients for pre-defined
        coordinate systems.

        Parameters
        ==========

        curv_coord_name : str
            Name of coordinate system

        r$   c                 S   s   t jt jt jfS r1   r   r`   r(   r.   r.   r/   r0   g      z,CoordSys3D._get_lame_coeff.<locals>.<lambda>r7   c                 S   s   t j| | t| fS r1   )r   r`   r   r8   r.   r.   r/   r0   i  s    r;   c                 S   s   t j| t jfS r1   r   r-   r9   hr.   r.   r/   r0   k  s    zAWrong set of parameters. Type of coordinate system is not defined)rO   rJ   rQ   r   _calculate_lame_coefficientsr   r.   r.   r/   r]   X  s   

zCoordSys3D._get_lame_coeffc                    s    fddS )z
        It calculates Lame coefficients
        for given transformations equations.

        Parameters
        ==========

        equations : Lambda
            Lambda of transformation equations.

        c              	      s   t t | ||d | d t | ||d | d  t | ||d | d  t t | ||d |d t | ||d |d  t | ||d |d  t t | ||d |d t | ||d |d  t | ||d |d  fS )Nr   r%   r    )r   r   r3   r   r.   r/   r0   }  s    z2CoordSys3D._calculate_lame_coeff.<locals>.<lambda>r.   r   r.   r   r/   rc   p  s   z CoordSys3D._calculate_lame_coeffc                 C   s   t | jd S )z2
        Returns inverse rotation matrix.
        )r   rt   r   r.   r.   r/   _inverse_rotation_matrix  s   z#CoordSys3D._inverse_rotation_matrixc                 C   sF   t | tr!| dkrdd S | dkrdd S | dkrdd S tdd	S )
z
        Store information about transformation equations for pre-defined
        coordinate systems.

        Parameters
        ==========

        curv_coord_name : str
            Name of coordinate system

        r$   c                 S   r   r1   r.   r(   r.   r.   r/   r0     r   z8CoordSys3D._get_transformation_lambdas.<locals>.<lambda>r7   c                 S   s2   | t | t| | t | t | | t| fS r1   )r   r   r8   r.   r.   r/   r0     s   
r;   c                 S   s   | t | | t| |fS r1   )r   r   r   r.   r.   r/   r0     s   

r   N)rO   rJ   rQ   r   r.   r.   r/   r^     s   
z&CoordSys3D._get_transformation_lambdasc                 C   s   t |t| S )z
        Returns the transformation equations obtained from rotation matrix.

        Parameters
        ==========

        matrix : Matrix
            Rotation matrix

        equations : tuple
            Transformation equations

        )rR   r'   )r"   matrixr   r.   r.   r/   _rotation_trans_equations  s   z$CoordSys3D._rotation_trans_equationsc                 C   r   r1   )ru   r   r.   r.   r/   rY     s   zCoordSys3D.originc                 C   r   r1   )rj   r   r.   r.   r/   r     r   zCoordSys3D.base_vectorsc                 C   r   r1   )rl   r   r.   r.   r/   base_scalars  r   zCoordSys3D.base_scalarsc                 C   r   r1   )ro   r   r.   r.   r/   r_     r   zCoordSys3D.lame_coefficientsc                 C   s   | j |   S r1   )rn   r   r   r.   r.   r/   transformation_to_parent  s   z#CoordSys3D.transformation_to_parentc                 C   s"   | j d u r	td| j| j   S )NzHno parent coordinate system, use `transformation_from_parent_function()`)rr   rQ   rp   r   r   r.   r.   r/   transformation_from_parent  s
   
z%CoordSys3D.transformation_from_parentc                 C   r   r1   )rp   r   r.   r.   r/   #transformation_from_parent_function  r   z.CoordSys3D.transformation_from_parent_functionc                 C   s   ddl m} t|tstt|d || krtdS || jkr#| jS |j| kr,|jj	S || |\}}td}d}t
|D ]	}||| j9 }q=|d7 }|t|k rc||| jj	9 }|d7 }|t|k sQ|S )ar  
        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   r%   r    )sympy.vector.functionsr   rO   r   rP   rJ   r   rr   rt   Trangelen)r   otherr   	rootindexpathresultr<   r.   r.   r/   rx     s,   !


zCoordSys3D.rotation_matrixc                 C   s   | j |S )ab  
        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

        )rY   position_wrt)r   r   r.   r.   r/   r     s   zCoordSys3D.position_wrtc                    sZ   t | ||  fddt| D }| |t| fddt|  D S )as  
        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}

        c                    s   g | ]
\}}| |  qS r.   r.   rB   r<   r)   )origin_coordsr.   r/   rE   E  s    z)CoordSys3D.scalar_map.<locals>.<listcomp>c                    s   i | ]\}}|t  | qS r.   r   r   )vars_matrixr.   r/   
<dictcomp>J  s    z)CoordSys3D.scalar_map.<locals>.<dictcomp>)rR   r   	to_matrix	enumerater   rx   r'   )r   r   relocated_scalarsr.   )r   r   r/   
scalar_map+  s   



zCoordSys3D.scalar_mapc                 C   s.   |du r| j }|du r| j}t||||| dS )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

        N)rw   r?   rI   rv   )rk   rh   r   )r   rD   positionr?   rI   r.   r.   r/   rZ   M  s   zCoordSys3D.locate_newc                 C   s   |du r| j }|du r| j}t|tr't|tr|| }n| }t|}nttd}|D ]}t|tr>||| 9 }q/|| 9 }q/t	|||||| dS )at  
        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, ))
        Nr#   )rx   r?   rI   rw   rv   )
rk   rh   rO   r   r   rx   r   r'   r   r   )r   rD   	orientersrw   r?   rI   final_matrixorienterr.   r.   r/   
orient_newv  s(   A



zCoordSys3D.orient_newc                 C   s:   |du r| j }|du r| j}t||}| j|||||dS )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)

        Nrw   r?   rI   )rk   rh   r   r   )r   rD   angleaxisrw   r?   rI   r   r.   r.   r/   orient_new_axis  s   '
zCoordSys3D.orient_new_axisc	           
      C   "   t ||||}	| j||	|||dS )an  
        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   rD   angle1angle2angle3rotation_orderrw   r?   rI   r   r.   r.   r/   orient_new_body  s   AzCoordSys3D.orient_new_bodyc	           
      C   r   )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   r.   r.   r/   orient_new_spaceN  s   ;zCoordSys3D.orient_new_spacec	           
      C   r   )aF  
        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   rD   q0q1q2q3rw   r?   rI   r   r.   r.   r/   orient_new_quaternion  s   1z CoordSys3D.orient_new_quaternionc                 C   s   t || |||dS )a
  
        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))

        )rv   r2   rI   r?   )r   )r   rD   r2   rI   r?   r.   r.   r/   
create_new  s   zCoordSys3D.create_newc                 C   s   d S r1   r.   )r   rD   rw   rx   rv   r?   rI   r~   r   r   r   r2   r.   r.   r/   __init__  s   zCoordSys3D.__init__c                    sR   fdd|d u rS fdd|  D \  fddfddS )Nc                    s   t  | ||fS r1   )r   r   r(   )rotr.   r/   r0     s    z>CoordSys3D._compose_rotation_and_translation.<locals>.<lambda>c                    s   g | ]}  |qS r.   )r   r   )translationr.   r/   rE     s    z@CoordSys3D._compose_rotation_and_translation.<locals>.<listcomp>c                    s   |   | | fS r1   r.   r(   )dxdydzr.   r/   r0     s   c                    s    | || S r1   r.   r(   )r-   tr.   r/   r0     r   )r   )r   r   rv   r.   )r   r   r   r-   r   r   r   r/   r[     s   z,CoordSys3D._compose_rotation_and_translation)NNNNNN)NN)NNN)
NNNNNNNNNN)'__name__
__module____qualname____doc__re   r   r   staticmethodrb   ra   r   r]   rc   r   r^   classmethodr   propertyrY   r   r   r_   r   r   r   rx   r   r   r   rZ   r   r   r   r   r   r   r   r[   __classcell__r.   r.   r   r/   r      sz     a
"





8
"
)
_
3
H
A

7"
r   c                 C   s<   | d }t |dkrt||D ]}t|tst|qd S )Nz& must be an iterable of 3 string-typesr#   )r   rQ   rO   rJ   rP   )arg_nameargerrorstrsr.   r.   r/   rg      s   
rg   )ri   )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.vectorrK   sympy.vector.orientersr   r   r   r   r   r   rg   sympy.vector.vectorri   r.   r.   r.   r/   <module>   s<           n
