U
    ZÊ¹j  ã                   @   s’   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dgZ
G dd„ deedd	d
gƒƒZG dd„ deƒZG dd„ deƒZdd„ Zdd„ ZdS )é    )ÚABC)Ú
namedtuple)ÚBodyBase)ÚVectorÚReferenceFrameÚPointÚLoadBaseÚForceÚTorquec                   @   s(   e Zd ZdZdd„ Zdd„ ZeZeZdS )r   z2Abstract base class for the various loading types.c                 C   s"   t d| jj› d|jj› d�ƒ‚d S )Nz$unsupported operand type(s) for +: 'ú' and 'ú'©Ú	TypeErrorÚ	__class__Ú__name__©ÚselfÚother© r   ú\/var/www/html/bwave/python/venv/lib/python3.8/site-packages/sympy/physics/mechanics/loads.pyÚ__add__   s    zLoadBase.__add__c                 C   s"   t d| jj› d|jj› d�ƒ‚d S )Nz$unsupported operand type(s) for *: 'r   r   r   r   r   r   r   Ú__mul__   s    zLoadBase.__mul__N)r   Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__radd__Ú__rmul__r   r   r   r   r   	   s
   ÚlocationÚvectorc                       s@   e Zd ZdZ‡ fdd„Zdd„ Zedd„ ƒZedd	„ ƒZ‡  Z	S )
r	   a+  Force acting upon a point.

    Explanation
    ===========

    A force is a vector that is bound to a line of action. This class stores
    both a point, which lies on the line of action, and the vector. A tuple can
    also be used, with the location as the first entry and the vector as second
    entry.

    Examples
    ========

    A force of magnitude 2 along N.x acting on a point Po can be created as
    follows:

    >>> from sympy.physics.mechanics import Point, ReferenceFrame, Force
    >>> N = ReferenceFrame('N')
    >>> Po = Point('Po')
    >>> Force(Po, 2 * N.x)
    (Po, 2*N.x)

    If a body is supplied, then the center of mass of that body is used.

    >>> from sympy.physics.mechanics import Particle
    >>> P = Particle('P', point=Po)
    >>> Force(P, 2 * N.x)
    (Po, 2*N.x)

    c                    sD   t |tƒr|j}t |tƒs"tdƒ‚t |tƒs4tdƒ‚tƒ  | ||¡S )Nz!Force location should be a Point.z Force vector should be a Vector.)Ú
isinstancer   Ú
masscenterr   r   r   ÚsuperÚ__new__)ÚclsÚpointÚforce©r   r   r   r"   :   s    


zForce.__new__c                 C   s   | j j› d| j› d| j› d�S )Nz(point=z, force=ú))r   r   r$   r%   ©r   r   r   r   Ú__repr__C   s    zForce.__repr__c                 C   s   | j S ©N©r   r(   r   r   r   r$   G   s    zForce.pointc                 C   s   | j S r*   ©r   r(   r   r   r   r%   K   s    zForce.force)
r   r   r   r   r"   r)   Úpropertyr$   r%   Ú__classcell__r   r   r&   r   r	      s   	
c                       s@   e Zd ZdZ‡ fdd„Zdd„ Zedd„ ƒZedd	„ ƒZ‡  Z	S )
r
   a  Torque acting upon a frame.

    Explanation
    ===========

    A torque is a free vector that is acting on a reference frame, which is
    associated with a rigid body. This class stores both the frame and the
    vector. A tuple can also be used, with the location as the first item and
    the vector as second item.

    Examples
    ========

    A torque of magnitude 2 about N.x acting on a frame N can be created as
    follows:

    >>> from sympy.physics.mechanics import ReferenceFrame, Torque
    >>> N = ReferenceFrame('N')
    >>> Torque(N, 2 * N.x)
    (N, 2*N.x)

    If a body is supplied, then the frame fixed to that body is used.

    >>> from sympy.physics.mechanics import RigidBody
    >>> rb = RigidBody('rb', frame=N)
    >>> Torque(rb, 2 * N.x)
    (N, 2*N.x)

    c                    sD   t |tƒr|j}t |tƒs"tdƒ‚t |tƒs4tdƒ‚tƒ  | ||¡S )Nz+Torque location should be a ReferenceFrame.z!Torque vector should be a Vector.)r   r   Úframer   r   r   r!   r"   )r#   r/   Útorquer&   r   r   r"   o   s    


zTorque.__new__c                 C   s   | j j› d| j› d| j› d�S )Nz(frame=z	, torque=r'   )r   r   r/   r0   r(   r   r   r   r)   x   s    zTorque.__repr__c                 C   s   | j S r*   r+   r(   r   r   r   r/   |   s    zTorque.framec                 C   s   | j S r*   r,   r(   r   r   r   r0   €   s    zTorque.torque)
r   r   r   r   r"   r)   r-   r/   r0   r.   r   r   r&   r   r
   P   s   	
c                 G   sF   g }|D ]8}t |tƒs(tt|ƒ› d�ƒ‚| t|j|j|  ƒ¡ q|S )a  
    Returns a list of gravity forces given the acceleration
    due to gravity and any number of particles or rigidbodies.

    Example
    =======

    >>> from sympy.physics.mechanics import ReferenceFrame, Particle, RigidBody
    >>> from sympy.physics.mechanics.loads import gravity
    >>> from sympy import symbols
    >>> N = ReferenceFrame('N')
    >>> g = symbols('g')
    >>> P = Particle('P')
    >>> B = RigidBody('B')
    >>> gravity(g*N.y, P, B)
    [(P_masscenter, P_mass*g*N.y),
     (B_masscenter, B_mass*g*N.y)]

    z is not a body type)r   r   r   ÚtypeÚappendr	   r    Zmass)ZaccelerationZbodiesZgravity_forceÚbodyr   r   r   Úgravity…   s    
r4   c                 C   s    t | tƒr| S t | tƒrˆt| ƒdkr4td| › d�ƒ‚t | d tƒrTt| d | d ƒS t | d tƒrtt| d | d ƒS td| d › d�ƒ‚t	dt
| ƒ› d	�ƒ‚d
S )zBHelper function to parse loads and convert tuples to load objects.é   zLoad z should have a length of 2.r   é   z'Load not recognized. The load location z. should either be a Point or a ReferenceFrame.z
Load type zA not recognized as a load. It should be a Force, Torque or tuple.N)r   r   ÚtupleÚlenÚ
ValueErrorr   r	   r   r
   r   r1   )Úloadr   r   r   Ú_parse_load¢   s    

r;   N)Úabcr   Úcollectionsr   Z!sympy.physics.mechanics.body_baser   Zsympy.physics.vectorr   r   r   Ú__all__r   r	   r
   r4   r;   r   r   r   r   Ú<module>   s   
65