o
    oÇhUP  ã                   @   sL   d dl mZmZ d dlmZ ddlmZ ddlmZ dgZ	G dd„ dƒZ
dS )	é   )ÚVectorÚ_check_vector)Ú_check_frameé    )Úwarn)Ú
filldedentÚPointc                   @   s”   e Zd ZdZdd„ Zdd„ Ze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„ Zdd„ Zd d!„ Zd"S )#r   ad  This object represents a point in a dynamic system.

    It stores the: position, velocity, and acceleration of a point.
    The position is a vector defined as the vector distance from a parent
    point to this point.

    Parameters
    ==========

    name : string
        The display name of the Point

    Examples
    ========

    >>> from sympy.physics.vector import Point, ReferenceFrame, dynamicsymbols
    >>> from sympy.physics.vector import init_vprinting
    >>> init_vprinting(pretty_print=False)
    >>> N = ReferenceFrame('N')
    >>> O = Point('O')
    >>> P = Point('P')
    >>> u1, u2, u3 = dynamicsymbols('u1 u2 u3')
    >>> O.set_vel(N, u1 * N.x + u2 * N.y + u3 * N.z)
    >>> O.acc(N)
    u1'*N.x + u2'*N.y + u3'*N.z

    ``symbols()`` can be used to create multiple Points in a single step, for
    example:

    >>> from sympy.physics.vector import Point, ReferenceFrame, dynamicsymbols
    >>> from sympy.physics.vector import init_vprinting
    >>> init_vprinting(pretty_print=False)
    >>> from sympy import symbols
    >>> N = ReferenceFrame('N')
    >>> u1, u2 = dynamicsymbols('u1 u2')
    >>> A, B = symbols('A B', cls=Point)
    >>> type(A)
    <class 'sympy.physics.vector.point.Point'>
    >>> A.set_vel(N, u1 * N.x + u2 * N.y)
    >>> B.set_vel(N, u2 * N.x + u1 * N.y)
    >>> A.acc(N) - B.acc(N)
    (u1' - u2')*N.x + (-u1' + u2')*N.y

    c                 C   s.   || _ i | _i | _i | _| j| j| jg| _dS )z"Initialization of a Point object. N)ÚnameÚ	_pos_dictÚ	_vel_dictÚ	_acc_dictÚ_pdlist)Úselfr	   © r   ún/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/physics/vector/point.pyÚ__init__7   s
   zPoint.__init__c                 C   s   | j S )N)r	   )r   r   r   r   Ú__str__?   s   zPoint.__str__c                 C   s   t |tƒs	tdƒ‚d S )NzA Point must be supplied)Ú
isinstancer   Ú	TypeError)r   Úotherr   r   r   Ú_check_pointD   s   
ÿzPoint._check_pointc           	      C   sÐ   | gg}g g}||kr<|dd… }|D ]$}|d j |  ¡ }|D ]}| |¡s6||g }| |¡s6| |¡ q q||ks|D ]}|d |krK| |¡ q>|jtd t|ƒdkr\|d S td|j d | j ƒ‚)aM  Returns a list of points that gives the shortest path with respect
        to position, velocity, or acceleration from this point to the provided
        point.

        Parameters
        ==========
        other : Point
            A point that may be related to this point by position, velocity, or
            acceleration.
        num : integer
            0 for searching the position tree, 1 for searching the velocity
            tree, and 2 for searching the acceleration tree.

        Returns
        =======
        list of Points
            A sequence of points from self to other.

        Notes
        =====

        It is not clear if num = 1 or num = 2 actually works because the keys
        to ``_vel_dict`` and ``_acc_dict`` are :class:`ReferenceFrame` objects
        which do not have the ``_pdlist`` attribute.

        Néÿÿÿÿ)Úkeyr   z!No Connecting Path found between z and )	r   ÚkeysÚ__contains__ÚappendÚremoveÚsortÚlenÚ
ValueErrorr	   )	r   r   ÚnumÚoutlistÚoldlistÚvÚtemplistÚv2Úlittletemplistr   r   r   Ú_pdict_listH   s4   



€üü	
€
ÿÿzPoint._pdict_listc           
   	   C   s˜   t |ƒ t |ƒ |  |¡ |  |¡}|  |¡}| |¡}|  |¡}| |¡}| |¡}	|  ||d| |¡  | |	 |¡ | | |¡¡ ¡ |  |¡S )a³  Sets the acceleration of this point with the 1-point theory.

        The 1-point theory for point acceleration looks like this:

        ^N a^P = ^B a^P + ^N a^O + ^N alpha^B x r^OP + ^N omega^B x (^N omega^B
        x r^OP) + 2 ^N omega^B x ^B v^P

        where O is a point fixed in B, P is a point moving in B, and B is
        rotating in frame N.

        Parameters
        ==========

        otherpoint : Point
            The first point of the 1-point theory (O)
        outframe : ReferenceFrame
            The frame we want this point's acceleration defined in (N)
        fixedframe : ReferenceFrame
            The intermediate frame in this calculation (B)

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> from sympy.physics.vector import dynamicsymbols
        >>> from sympy.physics.vector import init_vprinting
        >>> init_vprinting(pretty_print=False)
        >>> q = dynamicsymbols('q')
        >>> q2 = dynamicsymbols('q2')
        >>> qd = dynamicsymbols('q', 1)
        >>> q2d = dynamicsymbols('q2', 1)
        >>> N = ReferenceFrame('N')
        >>> B = ReferenceFrame('B')
        >>> B.set_ang_vel(N, 5 * B.y)
        >>> O = Point('O')
        >>> P = O.locatenew('P', q * B.x + q2 * B.y)
        >>> P.set_vel(B, qd * B.x + q2d * B.y)
        >>> O.set_vel(N, 0)
        >>> P.a1pt_theory(O, N, B)
        (-25*q + q'')*B.x + q2''*B.y - 10*q'*B.z

        é   )	r   r   Úpos_fromÚvelÚaccÚ
ang_vel_inÚ
ang_acc_inÚset_accÚcross)
r   Ú
otherpointÚoutframeÚ
interframeÚdistr#   Úa1Úa2ÚomegaÚalphar   r   r   Úa1pt_theoryw   s   ,






ÿÿ
zPoint.a1pt_theoryc              	   C   sr   t |ƒ t |ƒ |  |¡ |  |¡}| |¡}| |¡}| |¡}|  ||| |¡ | | |¡¡ ¡ |  |¡S )a¬  Sets the acceleration of this point with the 2-point theory.

        The 2-point theory for point acceleration looks like this:

        ^N a^P = ^N a^O + ^N alpha^B x r^OP + ^N omega^B x (^N omega^B x r^OP)

        where O and P are both points fixed in frame B, which is rotating in
        frame N.

        Parameters
        ==========

        otherpoint : Point
            The first point of the 2-point theory (O)
        outframe : ReferenceFrame
            The frame we want this point's acceleration defined in (N)
        fixedframe : ReferenceFrame
            The frame in which both points are fixed (B)

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame, dynamicsymbols
        >>> from sympy.physics.vector import init_vprinting
        >>> init_vprinting(pretty_print=False)
        >>> q = dynamicsymbols('q')
        >>> qd = dynamicsymbols('q', 1)
        >>> N = ReferenceFrame('N')
        >>> B = N.orientnew('B', 'Axis', [q, N.z])
        >>> O = Point('O')
        >>> P = O.locatenew('P', 10 * B.x)
        >>> O.set_vel(N, 5 * N.x)
        >>> P.a2pt_theory(O, N, B)
        - 10*q'**2*B.x + 10*q''*B.y

        )r   r   r)   r+   r,   r-   r.   r/   )r   r0   r1   Ú
fixedframer3   Úar6   r7   r   r   r   Úa2pt_theory°   s   &




ÿ
zPoint.a2pt_theoryc                 C   sB   t |ƒ || jvr|  |¡dkr| j|  |¡S tdƒS | j| S )aÜ  The acceleration Vector of this Point in a ReferenceFrame.

        Parameters
        ==========

        frame : ReferenceFrame
            The frame in which the returned acceleration vector will be defined
            in.

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p1.set_acc(N, 10 * N.x)
        >>> p1.acc(N)
        10*N.x

        r   )r   r   r*   r   Údtr   )r   Úframer   r   r   r+   á   s   

z	Point.accc                 C   sP   t |tƒs	tdƒ‚|dkrtdƒ}t|ƒ}t|ƒ}| | |¡ |  || ¡ |S )aÖ  Creates a new point with a position defined from this point.

        Parameters
        ==========

        name : str
            The name for the new point
        value : Vector
            The position of the new point relative to this point

        Examples
        ========

        >>> from sympy.physics.vector import ReferenceFrame, Point
        >>> N = ReferenceFrame('N')
        >>> P1 = Point('P1')
        >>> P2 = P1.locatenew('P2', 10 * N.x)

        zMust supply a valid namer   )r   Ústrr   r   r   r   Úset_pos)r   r	   ÚvalueÚpr   r   r   Ú	locatenewÿ   s   
zPoint.locatenewc                 C   sH   t dƒ}|  |d¡}tt|ƒd ƒD ]}||| j||d   7 }q|S )aã  Returns a Vector distance between this Point and the other Point.

        Parameters
        ==========

        otherpoint : Point
            The otherpoint we are locating this one relative to

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p2 = Point('p2')
        >>> p1.set_pos(p2, 10 * N.x)
        >>> p1.pos_from(p2)
        10*N.x

        r   r   )r   r'   Úranger   r
   )r   r0   ÚoutvecÚplistÚir   r   r   r)     s
   zPoint.pos_fromc                 C   ó4   |dkrt dƒ}t|ƒ}t|ƒ | j ||i¡ dS )a#  Used to set the acceleration of this Point in a ReferenceFrame.

        Parameters
        ==========

        frame : ReferenceFrame
            The frame in which this point's acceleration is defined
        value : Vector
            The vector value of this point's acceleration in the frame

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p1.set_acc(N, 10 * N.x)
        >>> p1.acc(N)
        10*N.x

        r   N)r   r   r   r   Úupdate©r   r=   r@   r   r   r   r.   :  ó
   zPoint.set_accc                 C   sH   |dkrt dƒ}t|ƒ}|  |¡ | j ||i¡ |j | | i¡ dS )aD  Used to set the position of this point w.r.t. another point.

        Parameters
        ==========

        otherpoint : Point
            The other point which this point's location is defined relative to
        value : Vector
            The vector which defines the location of this point

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p2 = Point('p2')
        >>> p1.set_pos(p2, 10 * N.x)
        >>> p1.pos_from(p2)
        10*N.x

        r   N)r   r   r   r
   rH   )r   r0   r@   r   r   r   r?   W  s   
zPoint.set_posc                 C   rG   )a  Sets the velocity Vector of this Point in a ReferenceFrame.

        Parameters
        ==========

        frame : ReferenceFrame
            The frame in which this point's velocity is defined
        value : Vector
            The vector value of this point's velocity in the frame

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p1.set_vel(N, 10 * N.x)
        >>> p1.vel(N)
        10*N.x

        r   N)r   r   r   r   rH   rI   r   r   r   Úset_velv  rJ   zPoint.set_velc                 C   sf   t |ƒ t |ƒ |  |¡ |  |¡}|  |¡}| |¡}| |¡}|  ||| | |¡ ¡ |  |¡S )aV  Sets the velocity of this point with the 1-point theory.

        The 1-point theory for point velocity looks like this:

        ^N v^P = ^B v^P + ^N v^O + ^N omega^B x r^OP

        where O is a point fixed in B, P is a point moving in B, and B is
        rotating in frame N.

        Parameters
        ==========

        otherpoint : Point
            The first point of the 1-point theory (O)
        outframe : ReferenceFrame
            The frame we want this point's velocity defined in (N)
        interframe : ReferenceFrame
            The intermediate frame in this calculation (B)

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> from sympy.physics.vector import dynamicsymbols
        >>> from sympy.physics.vector import init_vprinting
        >>> init_vprinting(pretty_print=False)
        >>> q = dynamicsymbols('q')
        >>> q2 = dynamicsymbols('q2')
        >>> qd = dynamicsymbols('q', 1)
        >>> q2d = dynamicsymbols('q2', 1)
        >>> N = ReferenceFrame('N')
        >>> B = ReferenceFrame('B')
        >>> B.set_ang_vel(N, 5 * B.y)
        >>> O = Point('O')
        >>> P = O.locatenew('P', q * B.x + q2 * B.y)
        >>> P.set_vel(B, qd * B.x + q2d * B.y)
        >>> O.set_vel(N, 0)
        >>> P.v1pt_theory(O, N, B)
        q'*B.x + q2'*B.y - 5*q*B.z

        ©r   r   r)   r*   r,   rK   r/   )r   r0   r1   r2   r3   Úv1r%   r6   r   r   r   Úv1pt_theory“  s   +





zPoint.v1pt_theoryc                 C   sX   t |ƒ t |ƒ |  |¡ |  |¡}| |¡}| |¡}|  ||| |¡ ¡ |  |¡S )as  Sets the velocity of this point with the 2-point theory.

        The 2-point theory for point velocity looks like this:

        ^N v^P = ^N v^O + ^N omega^B x r^OP

        where O and P are both points fixed in frame B, which is rotating in
        frame N.

        Parameters
        ==========

        otherpoint : Point
            The first point of the 2-point theory (O)
        outframe : ReferenceFrame
            The frame we want this point's velocity defined in (N)
        fixedframe : ReferenceFrame
            The frame in which both points are fixed (B)

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame, dynamicsymbols
        >>> from sympy.physics.vector import init_vprinting
        >>> init_vprinting(pretty_print=False)
        >>> q = dynamicsymbols('q')
        >>> qd = dynamicsymbols('q', 1)
        >>> N = ReferenceFrame('N')
        >>> B = N.orientnew('B', 'Axis', [q, N.z])
        >>> O = Point('O')
        >>> P = O.locatenew('P', 10 * B.x)
        >>> O.set_vel(N, 5 * N.x)
        >>> P.v2pt_theory(O, N, B)
        5*N.x + 10*q'*B.y

        rL   )r   r0   r1   r9   r3   r#   r6   r   r   r   Úv2pt_theoryÈ  s   &




zPoint.v2pt_theoryc                 C   sx  t |ƒ || jvr·d}d}g }| g}g }|ry| d¡}||vrw| |¡ |j ¡ D ]M\}}	||v r2q)z|	 |¡ W n	 tyB   Y q)w ||v rId}z|j| }
W n ty^   | |¡ Y q)w | |¡ |sv|  	||  
|¡ |¡|
 ¡ d}q)|s|rttdƒƒ t|ƒdkr¡ttd| j› d|d j› dt|dd	… ƒ› d
ƒƒ |r¨| j| S ttd| j› d|j› dƒƒ‚| j| S )a¾  The velocity Vector of this Point in the ReferenceFrame.

        Parameters
        ==========

        frame : ReferenceFrame
            The frame in which the returned velocity vector will be defined in

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame, dynamicsymbols
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p1.set_vel(N, 10 * N.x)
        >>> p1.vel(N)
        10*N.x

        Velocities will be automatically calculated if possible, otherwise a
        ``ValueError`` will be returned. If it is possible to calculate
        multiple different velocities from the relative points, the points
        defined most directly relative to this point will be used. In the case
        of inconsistent relative positions of points, incorrect velocities may
        be returned. It is up to the user to define prior relative positions
        and velocities of points in a self-consistent way.

        >>> p = Point('p')
        >>> q = dynamicsymbols('q')
        >>> p.set_vel(N, 10 * N.x)
        >>> p2 = Point('p2')
        >>> p2.set_pos(p, q*N.x)
        >>> p2.vel(N)
        (Derivative(q(t), t) + 10)*N.x

        Fr   Tz²
                Kinematic loops are defined among the positions of points. This
                is likely not desired and may cause errors in your calculations.
                r   z
                Velocity of z9 automatically calculated based on point
                z9 but it is also possible from
                points(s): Nzˆ. Velocities from these
                points are not necessarily the same. This may cause errors in
                your calculations.z#
                Velocity of point z8 has not been defined in
                ReferenceFrame Ú.)r   r   Úpopr   r
   ÚitemsÚexpressr   ÚKeyErrorrK   r)   r<   r   r   r   r	   r>   )r   r=   Úvalid_neighbor_foundÚ	is_cyclicÚvisitedÚqueueÚcandidate_neighborÚnodeÚneighborÚneighbor_posÚneighbor_velocityr   r   r   r*   ÷  sf   %


ÿ
þ
€éÿþý
ÿþ
z	Point.velc                 G   sD   ddl m} |  |¡}||g||ƒd }t|ƒdkr|d S t|ƒS )a  Returns the partial velocities of the linear velocity vector of this
        point in the given frame with respect to one or more provided
        generalized speeds.

        Parameters
        ==========
        frame : ReferenceFrame
            The frame with which the velocity is defined in.
        gen_speeds : functions of time
            The generalized speeds.

        Returns
        =======
        partial_velocities : tuple of Vector
            The partial velocity vectors corresponding to the provided
            generalized speeds.

        Examples
        ========

        >>> from sympy.physics.vector import ReferenceFrame, Point
        >>> from sympy.physics.vector import dynamicsymbols
        >>> N = ReferenceFrame('N')
        >>> A = ReferenceFrame('A')
        >>> p = Point('p')
        >>> u1, u2 = dynamicsymbols('u1, u2')
        >>> p.set_vel(N, u1 * N.x + u2 * A.y)
        >>> p.partial_velocity(N, u1)
        N.x
        >>> p.partial_velocity(N, u1, u2)
        (N.x, A.y)

        r   )Úpartial_velocityr   )Úsympy.physics.vector.functionsr^   r*   r   Útuple)r   r=   Ú
gen_speedsr^   r*   Úpartialsr   r   r   r^   P  s   #
zPoint.partial_velocityN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__repr__r   r'   r8   r;   r+   rB   r)   r.   r?   rK   rN   rO   r*   r^   r   r   r   r   r   	   s&    -/915/YN)Úvectorr   r   r=   r   Úwarningsr   Úsympy.utilities.miscr   Ú__all__r   r   r   r   r   Ú<module>   s    