o
    oÇh?  ã                   @   s>   d Z ddlmZ ddlm  mZ 		ddd„Zdd	d
„Z	dS )zOThis module contains some sample symbolic models used for testing and
examples.é    )ÚbackendNé   Fc              	   C   sü  t  d | ¡¡}t  d | ¡¡}t  d | ¡¡}t  d¡}t d | ¡¡}t d | ¡¡}t d | ¡¡}	t d¡}
t d	¡}| |
d
¡ |g}g }g }g }t| ƒD ]š}|d  	d |¡|| |
j
 ¡}| |
|d  |
¡|| |
j
  ¡ | |¡ t d |¡||| ¡}| || ||  ¡  ¡ ||  ||  || ||   }z|||d  ||d   ||d  ||d    7 }W n	 tyÊ   Y nw |rÕ||| | 7 }|rÝ||	| 7 }| |||
j
 f¡ | |¡ qRtj|
|||d}| ||¡ |S )as  Returns a system containing the symbolic equations of motion and
    associated variables for a simple multi-degree of freedom point mass,
    spring, damper system with optional gravitational and external
    specified forces. For example, a two mass system under the influence of
    gravity and external forces looks like:

    ::

        ----------------
         |     |     |   | g
         \    | |    |   V
      k0 /    --- c0 |
         |     |     | x0, v0
        ---------    V
        |  m0   | -----
        ---------    |
         | |   |     |
         \ v  | |    |
      k1 / f0 --- c1 |
         |     |     | x1, v1
        ---------    V
        |  m1   | -----
        ---------
           | f1
           V

    Parameters
    ==========

    n : integer
        The number of masses in the serial chain.
    apply_gravity : boolean
        If true, gravity will be applied to each mass.
    apply_external_forces : boolean
        If true, a time varying external force will be applied to each mass.

    Returns
    =======

    kane : sympy.physics.mechanics.kane.KanesMethod
        A KanesMethod object.

    úm:{}zk:{}zc:{}Úgzx:{}zv:{}zf:{}ÚNÚoriginr   éÿÿÿÿzcenter{}zblock{}r   ©Úq_indÚu_indÚkd_eqs)ÚsmÚsymbolsÚformatÚmeÚdynamicsymbolsÚReferenceFrameÚPointÚset_velÚrangeÚ	locatenewÚxÚvelÚappendÚParticleÚdiffÚ
IndexErrorÚKanesMethodÚkanes_equations)ÚnÚapply_gravityÚapply_external_forcesÚmassÚ	stiffnessÚdampingÚacceleration_due_to_gravityÚcoordinatesÚspeedsÚ
specifiedsÚceilingr   ÚpointsÚkinematic_equationsÚ	particlesÚforcesÚiÚcenterÚblockÚtotal_forceÚkane© r3   úr/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/physics/mechanics/models.pyÚmulti_mass_spring_damper
   sZ   .


ÿÿ
ÿ
ÿÿ
ÿr5   Tc                 C   s4  | dkrt dƒ‚t d | d ¡¡}t d | d ¡¡}|du r*t d | d ¡¡}t d | d ¡¡}t d	 | ¡¡}t d
¡\}}	t d¡}
t d¡}| |
d¡ t d¡}| 	||d |
j
 ¡ | |
|d |
j
 ¡ t d||d ¡}|
g}|g}|g}||d  | |
j fg}|d  |	¡|d  g}|du s¡|du r¤g }nd}t| ƒD ]Å}|
 d |¡d||d  |
jg¡}| |
||d  |
j ¡ | |¡ |d  d |d ¡|| |j ¡}| |d |
|¡ | |¡ t dt|d ƒ |||d  ¡}| |¡ | |||d   | |
j f¡ |du r]| || ¡ |dkr4| |
||  |
j f¡ || d krH| ||| |
j f¡ n| ||| |
j ||d  |
j  f¡ | ||d   |	¡||d   ¡ qª|du r‰t d¡}| |||
j
 f¡ | |¡ tj|
|||d}| ||¡ |S )a-  Returns the system containing the symbolic first order equations of
    motion for a 2D n-link pendulum on a sliding cart under the influence of
    gravity.

    ::

                  |
         o    y   v
          \ 0 ^   g
           \  |
          --\-|----
          |  \|   |
      F-> |   o --|---> x
          |       |
          ---------
           o     o

    Parameters
    ==========

    n : integer
        The number of links in the pendulum.
    cart_force : boolean, default=True
        If true an external specified lateral force is applied to the cart.
    joint_torques : boolean, default=False
        If true joint torques will be added as specified inputs at each
        joint.

    Returns
    =======

    kane : sympy.physics.mechanics.kane.KanesMethod
        A KanesMethod object.

    Notes
    =====

    The degrees of freedom of the system are n + 1, i.e. one for each
    pendulum link and one for the lateral motion of the cart.

    M x' = F, where x = [u0, ..., un+1, q0, ..., qn+1]

    The joint angles are all defined relative to the ground where the x axis
    defines the ground line and the y axis points up. The joint torques are
    applied between each adjacent link and the between the cart and the
    lower link where a positive torque corresponds to positive angle.

    r   z/The number of links must be a positive integer.zq:{}r   zu:{}TzT1:{}r   zl:{}zg tÚIÚOÚP0ÚPa0NzB{}ÚAxisr   zP{}ÚPaÚFr	   )Ú
ValueErrorr   r   r   r   r   r   r   r   Úset_posr   r   Úyr   r   Ú	orientnewÚzÚset_ang_velr   r   Úv2pt_theoryÚstrr   r   )r   Ú
cart_forceÚjoint_torquesÚqÚuÚTÚmÚlr   Útr6   r7   r8   r9   Úframesr*   r,   r-   ÚkindiffsÚ	specifiedr.   ÚBiÚPiÚPair<   r2   r3   r3   r4   Ún_link_pendulum_on_cartp   sb   1


"
$
"
"

*&


rS   )r   FF)r   TF)
Ú__doc__Ú
sympy.corer   r   Úsympy.physics.mechanicsÚphysicsÚ	mechanicsr   r5   rS   r3   r3   r3   r4   Ú<module>   s   
ÿf