
    \h)`                     r    S SK Jr  S SKJrJrJrJr  S SKJrJ	r	J
r
  S SKJr  S SKJr  S/r " S S\\	5      rg)	    )Symbol)PointVectorReferenceFrameDyadic)	RigidBodyParticleInertia)BodyBase)sympy_deprecation_warningBodyc                       \ rS rSrSr  SS jrS r\S 5       r\S 5       r	\S 5       r
\S	 5       r\S
 5       r\R                  S 5       r\S 5       rS rSS jrSS jrS rSS jrS rS rS rSS jrSrg)r      a  
Body is a common representation of either a RigidBody or a Particle SymPy
object depending on what is passed in during initialization. If a mass is
passed in and central_inertia is left as None, the Particle object is
created. Otherwise a RigidBody object will be created.

.. deprecated:: 1.13
    The Body class is deprecated. Its functionality is captured by
    :class:`~.RigidBody` and :class:`~.Particle`.

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

The attributes that Body possesses will be the same as a Particle instance
or a Rigid Body instance depending on which was created. Additional
attributes are listed below.

Attributes
==========

name : string
    The body's name
masscenter : Point
    The point which represents the center of mass of the rigid body
frame : ReferenceFrame
    The reference frame which the body is fixed in
mass : Sympifyable
    The body's mass
inertia : (Dyadic, Point)
    The body's inertia around its center of mass. This attribute is specific
    to the rigid body form of Body and is left undefined for the Particle
    form
loads : iterable
    This list contains information on the different loads acting on the
    Body. Forces are listed as a (point, vector) tuple and torques are
    listed as (reference frame, vector) tuples.

Parameters
==========

name : String
    Defines the name of the body. It is used as the base for defining
    body specific properties.
masscenter : Point, optional
    A point that represents the center of mass of the body or particle.
    If no point is given, a point is generated.
mass : Sympifyable, optional
    A Sympifyable object which represents the mass of the body. If no
    mass is passed, one is generated.
frame : ReferenceFrame, optional
    The ReferenceFrame that represents the reference frame of the body.
    If no frame is given, a frame is generated.
central_inertia : Dyadic, optional
    Central inertia dyadic of the body. If none is passed while creating
    RigidBody, a default inertia is generated.

Examples
========

As Body has been deprecated, the following examples are for illustrative
purposes only. The functionality of Body is fully captured by
:class:`~.RigidBody` and :class:`~.Particle`. To ignore the deprecation
warning we can use the ignore_warnings context manager.

    >>> from sympy.utilities.exceptions import ignore_warnings

Default behaviour. This results in the creation of a RigidBody object for
which the mass, mass center, frame and inertia attributes are given default
values. ::

    >>> from sympy.physics.mechanics import Body
    >>> with ignore_warnings(DeprecationWarning):
    ...     body = Body('name_of_body')

This next example demonstrates the code required to specify all of the
values of the Body object. Note this will also create a RigidBody version of
the Body object. ::

    >>> from sympy import Symbol
    >>> from sympy.physics.mechanics import ReferenceFrame, Point, inertia
    >>> from sympy.physics.mechanics import Body
    >>> mass = Symbol('mass')
    >>> masscenter = Point('masscenter')
    >>> frame = ReferenceFrame('frame')
    >>> ixx = Symbol('ixx')
    >>> body_inertia = inertia(frame, ixx, 0, 0)
    >>> with ignore_warnings(DeprecationWarning):
    ...     body = Body('name_of_body', masscenter, mass, frame, body_inertia)

The minimal code required to create a Particle version of the Body object
involves simply passing in a name and a mass. ::

    >>> from sympy import Symbol
    >>> from sympy.physics.mechanics import Body
    >>> mass = Symbol('mass')
    >>> with ignore_warnings(DeprecationWarning):
    ...     body = Body('name_of_body', mass=mass)

The Particle version of the Body object can also receive a masscenter point
and a reference frame, just not an inertia.
Nc           
      T   [        SSSS9  / U l        Uc  [        US-   5      nUc  [        US-   5      nUcq  Ucn  [	        US-   5      n[	        US-   5      n[	        US	-   5      n[	        US
-   5      n	[	        US-   5      n
[	        US-   5      n[
        R                  " X$XgXX5      nOXR4nUc  [	        US-   5      nOUnUR                  US5        Uc1  Ub.  [        R                  " XX-5        X@l
        [        S5      U l        g [        R                  " XX-5        X@l
        Xl        g )Nz
            Support for the Body class has been removed, as its functionality is
            fully captured by RigidBody and Particle.
            z1.13zdeprecated-mechanics-body-class)deprecated_since_versionactive_deprecations_target_frame_masscenter_ixx_iyy_izz_izx_ixy_iyz_massr   )r   _loadsr   r   r   r
   from_inertia_scalarsset_velr   __init__framer   _central_inertiainertia)selfname
masscentermassr    central_inertiaixxiyyizzizxixyiyz_inertiar   s                 T/var/www/auris/envauris/lib/python3.13/site-packages/sympy/physics/mechanics/body.pyr   Body.__init__s   s:   ! &,'H	
 ="4(?3Etm34J"t|'C'C'C'C'C'C33Js47cHH (4H<4'>*EE5!$ "t'7d*<J$*1ID!d*<J#L    c                 |    U R                   (       a  [        R                  " U 5      $ [        R                  " U 5      $ N)is_rigidbodyr   __repr__r	   r#   s    r/   r5   Body.__repr__   s-    %%d++  &&r1   c                     U R                   $ r3   r   r6   s    r/   loads
Body.loads   s    {{r1   c                 .    U R                   R                  $ )z2The basis Vector for the Body, in the x direction.)r    xr6   s    r/   r=   Body.x        zz||r1   c                 .    U R                   R                  $ )z2The basis Vector for the Body, in the y direction.)r    yr6   s    r/   rA   Body.y   r?   r1   c                 .    U R                   R                  $ )z2The basis Vector for the Body, in the z direction.)r    zr6   s    r/   rD   Body.z   r?   r1   c                     U R                   (       a  [        R                  R                  U 5      $ U R                  U R
                  4$ )z<The body's inertia about a point; stored as (Dyadic, Point).)r4   r   r"   fgetr'   r%   r6   s    r/   r"   Body.inertia   s9     $$))$//$$doo66r1   c                 B    [         R                  R                  X5        g r3   )r   r"   fset)r#   Is     r/   r"   rH      s    t'r1   c                 (    [        U S5      (       a  gg)Nr.   TF)hasattrr6   s    r/   r4   Body.is_rigidbody   s    4$$r1   c                    [        U[        5      (       a  [        R                  nU R                  (       a\  [	        U R
                  U R                  U R                  U R                  U R                  U R                  45      R                  U5      $ [        U R
                  U R                  U R                  5      R                  U5      $ )a5  Kinetic energy of the body.

Parameters
==========

frame : ReferenceFrame or Body
    The Body's angular velocity and the velocity of it's mass
    center are typically defined with respect to an inertial frame but
    any relevant frame in which the velocities are known can be supplied.

Examples
========

As Body has been deprecated, the following examples are for illustrative
purposes only. The functionality of Body is fully captured by
:class:`~.RigidBody` and :class:`~.Particle`. To ignore the deprecation
warning we can use the ignore_warnings context manager.

>>> from sympy.utilities.exceptions import ignore_warnings
>>> from sympy.physics.mechanics import Body, ReferenceFrame, Point
>>> from sympy import symbols
>>> m, v, r, omega = symbols('m v r omega')
>>> N = ReferenceFrame('N')
>>> O = Point('O')
>>> with ignore_warnings(DeprecationWarning):
...     P = Body('P', masscenter=O, mass=m)
>>> P.masscenter.set_vel(N, v * N.y)
>>> P.kinetic_energy(N)
m*v**2/2

>>> N = ReferenceFrame('N')
>>> b = ReferenceFrame('b')
>>> b.set_ang_vel(N, omega * b.x)
>>> P = Point('P')
>>> P.set_vel(N, v * N.x)
>>> with ignore_warnings(DeprecationWarning):
...     B = Body('B', masscenter=P, frame=b)
>>> B.kinetic_energy(N)
B_ixx*omega**2/2 + B_mass*v**2/2

See Also
========

sympy.physics.mechanics : Particle, RigidBody

)
isinstancer   r    r4   r   r$   r%   r&   r'   kinetic_energyr	   )r#   r    s     r/   rQ   Body.kinetic_energy   s    ^ eT""JJETYYTYY!114??CEES^TYEZ[		4??DII>MMeTTr1   c                 |   [        U[        5      (       d  Uc  U R                  nO[        S5      e[        U[        5      (       d  [        S5      eUb  UR                  U* US9  U R                   H,  nX%;   d  M
  XS   -  nU R                  R                  U5          O   U R                  R                  X!45        g)a
  Add force to the body(s).

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

Applies the force on self or equal and opposite forces on
self and other body if both are given on the desired point on the bodies.
The force applied on other body is taken opposite of self, i.e, -force.

Parameters
==========

force: Vector
    The force to be applied.
point: Point, optional
    The point on self on which force is applied.
    By default self's masscenter.
reaction_body: Body, optional
    Second body on which equal and opposite force
    is to be applied.
reaction_point : Point, optional
    The point on other body on which equal and opposite
    force is applied. By default masscenter of other body.

Example
=======

As Body has been deprecated, the following examples are for illustrative
purposes only. The functionality of Body is fully captured by
:class:`~.RigidBody` and :class:`~.Particle`. To ignore the deprecation
warning we can use the ignore_warnings context manager.

>>> from sympy.utilities.exceptions import ignore_warnings
>>> from sympy import symbols
>>> from sympy.physics.mechanics import Body, Point, dynamicsymbols
>>> m, g = symbols('m g')
>>> with ignore_warnings(DeprecationWarning):
...     B = Body('B')
>>> force1 = m*g*B.z
>>> B.apply_force(force1) #Applying force on B's masscenter
>>> B.loads
[(B_masscenter, g*m*B_frame.z)]

We can also remove some part of force from any point on the body by
adding the opposite force to the body on that point.

>>> f1, f2 = dynamicsymbols('f1 f2')
>>> P = Point('P') #Considering point P on body B
>>> B.apply_force(f1*B.x + f2*B.y, P)
>>> B.loads
[(B_masscenter, g*m*B_frame.z), (P, f1(t)*B_frame.x + f2(t)*B_frame.y)]

Let's remove f1 from point P on body B.

>>> B.apply_force(-f1*B.x, P)
>>> B.loads
[(B_masscenter, g*m*B_frame.z), (P, f2(t)*B_frame.y)]

To further demonstrate the use of ``apply_force`` attribute,
consider two bodies connected through a spring.

>>> from sympy.physics.mechanics import Body, dynamicsymbols
>>> with ignore_warnings(DeprecationWarning):
...     N = Body('N') #Newtonion Frame
>>> x = dynamicsymbols('x')
>>> with ignore_warnings(DeprecationWarning):
...     B1 = Body('B1')
...     B2 = Body('B2')
>>> spring_force = x*N.x

Now let's apply equal and opposite spring force to the bodies.

>>> P1 = Point('P1')
>>> P2 = Point('P2')
>>> B1.apply_force(spring_force, point=P1, reaction_body=B2, reaction_point=P2)

We can check the loads(forces) applied to bodies now.

>>> B1.loads
[(P1, x(t)*N_frame.x)]
>>> B2.loads
[(P2, - x(t)*N_frame.x)]

Notes
=====

If a new force is applied to a body on a point which already has some
force applied on it, then the new force is added to the already applied
force on that point.

Nz-Force must be applied to a point on the body.zForce must be a vector.)point   )	rP   r   r%   	TypeErrorr   apply_forcer   removeappend)r#   forcerT   reaction_bodyreaction_pointloads         r/   rW   Body.apply_force  s    z %''} OPP%((566$%%ufN%CKKD}a ""4(	   	E>*r1   c                 J   [        U[        5      (       d  [        S5      eUb  UR                  U* 5        U R                   H7  nU R
                  U;   d  M  XS   -  nU R                  R                  U5          O   U R                  R                  U R
                  U45        g)aY  Add torque to the body(s).

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

Applies the torque on self or equal and opposite torques on
self and other body if both are given.
The torque applied on other body is taken opposite of self,
i.e, -torque.

Parameters
==========

torque: Vector
    The torque to be applied.
reaction_body: Body, optional
    Second body on which equal and opposite torque
    is to be applied.

Example
=======

As Body has been deprecated, the following examples are for illustrative
purposes only. The functionality of Body is fully captured by
:class:`~.RigidBody` and :class:`~.Particle`. To ignore the deprecation
warning we can use the ignore_warnings context manager.

>>> from sympy.utilities.exceptions import ignore_warnings
>>> from sympy import symbols
>>> from sympy.physics.mechanics import Body, dynamicsymbols
>>> t = symbols('t')
>>> with ignore_warnings(DeprecationWarning):
...     B = Body('B')
>>> torque1 = t*B.z
>>> B.apply_torque(torque1)
>>> B.loads
[(B_frame, t*B_frame.z)]

We can also remove some part of torque from the body by
adding the opposite torque to the body.

>>> t1, t2 = dynamicsymbols('t1 t2')
>>> B.apply_torque(t1*B.x + t2*B.y)
>>> B.loads
[(B_frame, t1(t)*B_frame.x + t2(t)*B_frame.y + t*B_frame.z)]

Let's remove t1 from Body B.

>>> B.apply_torque(-t1*B.x)
>>> B.loads
[(B_frame, t2(t)*B_frame.y + t*B_frame.z)]

To further demonstrate the use, let us consider two bodies such that
a torque `T` is acting on one body, and `-T` on the other.

>>> from sympy.physics.mechanics import Body, dynamicsymbols
>>> with ignore_warnings(DeprecationWarning):
...     N = Body('N') #Newtonion frame
...     B1 = Body('B1')
...     B2 = Body('B2')
>>> v = dynamicsymbols('v')
>>> T = v*N.y #Torque

Now let's apply equal and opposite torque to the bodies.

>>> B1.apply_torque(T, B2)

We can check the loads (torques) applied to bodies now.

>>> B1.loads
[(B1_frame, v(t)*N_frame.y)]
>>> B2.loads
[(B2_frame, - v(t)*N_frame.y)]

Notes
=====

If a new torque is applied on body which already has some torque applied on it,
then the new torque is added to the previous torque about the body's frame.

z(A Vector must be supplied to add torque.NrU   )rP   r   rV   apply_torquer   r    rX   rY   )r#   torquer[   r]   s       r/   r`   Body.apply_torqueu  s    f &&))FGG$&&w/KKDzzT!q'!""4(	  
 	DJJ/0r1   c                     / U l         g)al  
Clears the Body's loads list.

Example
=======

As Body has been deprecated, the following examples are for illustrative
purposes only. The functionality of Body is fully captured by
:class:`~.RigidBody` and :class:`~.Particle`. To ignore the deprecation
warning we can use the ignore_warnings context manager.

>>> from sympy.utilities.exceptions import ignore_warnings
>>> from sympy.physics.mechanics import Body
>>> with ignore_warnings(DeprecationWarning):
...     B = Body('B')
>>> force = B.x + B.y
>>> B.apply_force(force)
>>> B.loads
[(B_masscenter, B_frame.x + B_frame.y)]
>>> B.clear_loads()
>>> B.loads
[]

Nr9   r6   s    r/   clear_loadsBody.clear_loads  s    4 r1   c                     Ub!  [        U[        5      (       d  [        S5      eOU R                  nU R                   H%  nX;   d  M
  U R                  R                  U5          g   g)a  
Remove load about a point or frame.

Parameters
==========

about : Point or ReferenceFrame, optional
    The point about which force is applied,
    and is to be removed.
    If about is None, then the torque about
    self's frame is removed.

Example
=======

As Body has been deprecated, the following examples are for illustrative
purposes only. The functionality of Body is fully captured by
:class:`~.RigidBody` and :class:`~.Particle`. To ignore the deprecation
warning we can use the ignore_warnings context manager.

>>> from sympy.utilities.exceptions import ignore_warnings
>>> from sympy.physics.mechanics import Body, Point
>>> with ignore_warnings(DeprecationWarning):
...     B = Body('B')
>>> P = Point('P')
>>> f1 = B.x
>>> f2 = B.y
>>> B.apply_force(f1)
>>> B.apply_force(f2, P)
>>> B.loads
[(B_masscenter, B_frame.x), (P, B_frame.y)]

>>> B.remove_load(P)
>>> B.loads
[(B_masscenter, B_frame.x)]

Nz.Load is applied about Point or ReferenceFrame.)rP   r   rV   r    r   rX   )r#   aboutr]   s      r/   remove_loadBody.remove_load  s\    N eU++ PQQ , JJEKKD}""4(  r1   c                     [        U[        5      (       a  UnO![        U[        5      (       a  UR                  nU R                  R                  W5      $ )a8  
Returns the velocity of the mass center with respect to the provided
rigid body or reference frame.

Parameters
==========

body: Body or ReferenceFrame
    The rigid body or reference frame to calculate the velocity in.

Example
=======

As Body has been deprecated, the following examples are for illustrative
purposes only. The functionality of Body is fully captured by
:class:`~.RigidBody` and :class:`~.Particle`. To ignore the deprecation
warning we can use the ignore_warnings context manager.

>>> from sympy.utilities.exceptions import ignore_warnings
>>> from sympy.physics.mechanics import Body
>>> with ignore_warnings(DeprecationWarning):
...     A = Body('A')
...     B = Body('B')
>>> A.masscenter.set_vel(B.frame, 5*B.frame.x)
>>> A.masscenter_vel(B)
5*B_frame.x
>>> A.masscenter_vel(B.frame)
5*B_frame.x

)rP   r   r   r    r%   velr#   bodyr    s      r/   masscenter_velBody.masscenter_vel#  sB    @ d^,,Ed##JJE""5))r1   c                     [        U[        5      (       a  UnO![        U[        5      (       a  UR                  nU R                  R	                  W5      $ )ay  
Returns this body's angular velocity with respect to the provided
rigid body or reference frame.

Parameters
==========

body: Body or ReferenceFrame
    The rigid body or reference frame to calculate the angular velocity in.

Example
=======

As Body has been deprecated, the following examples are for illustrative
purposes only. The functionality of Body is fully captured by
:class:`~.RigidBody` and :class:`~.Particle`. To ignore the deprecation
warning we can use the ignore_warnings context manager.

>>> from sympy.utilities.exceptions import ignore_warnings
>>> from sympy.physics.mechanics import Body, ReferenceFrame
>>> with ignore_warnings(DeprecationWarning):
...     A = Body('A')
>>> N = ReferenceFrame('N')
>>> with ignore_warnings(DeprecationWarning):
...     B = Body('B', frame=N)
>>> A.frame.set_ang_vel(N, 5*N.x)
>>> A.ang_vel_in(B)
5*N.x
>>> A.ang_vel_in(N)
5*N.x

)rP   r   r   r    
ang_vel_inrl   s      r/   rq   Body.ang_vel_inI  sB    D d^,,Ed##JJEzz$$U++r1   c                     [        U[        5      (       a  UnO![        U[        5      (       a  UR                  nU R                  R	                  W5      $ )a  
Returns the direction cosine matrix of this body relative to the
provided rigid body or reference frame.

Parameters
==========

body: Body or ReferenceFrame
    The rigid body or reference frame to calculate the dcm.

Example
=======

As Body has been deprecated, the following examples are for illustrative
purposes only. The functionality of Body is fully captured by
:class:`~.RigidBody` and :class:`~.Particle`. To ignore the deprecation
warning we can use the ignore_warnings context manager.

>>> from sympy.utilities.exceptions import ignore_warnings
>>> from sympy.physics.mechanics import Body
>>> with ignore_warnings(DeprecationWarning):
...     A = Body('A')
...     B = Body('B')
>>> A.frame.orient_axis(B.frame, B.frame.x, 5)
>>> A.dcm(B)
Matrix([
[1,       0,      0],
[0,  cos(5), sin(5)],
[0, -sin(5), cos(5)]])
>>> A.dcm(B.frame)
Matrix([
[1,       0,      0],
[0,  cos(5), sin(5)],
[0, -sin(5), cos(5)]])

)rP   r   r   r    dcmrl   s      r/   rt   Body.dcmq  s@    L d^,,Ed##JJEzz~~e$$r1   c                     U R                   (       a  [        R                  " XU5      $ [        R                  " XU5      $ )a  Returns the inertia dyadic of the body with respect to another
point.

Parameters
==========

point : sympy.physics.vector.Point
    The point to express the inertia dyadic about.
frame : sympy.physics.vector.ReferenceFrame
    The reference frame used to construct the dyadic.

Returns
=======

inertia : sympy.physics.vector.Dyadic
    The inertia dyadic of the rigid body expressed about the provided
    point.

Example
=======

As Body has been deprecated, the following examples are for illustrative
purposes only. The functionality of Body is fully captured by
:class:`~.RigidBody` and :class:`~.Particle`. To ignore the deprecation
warning we can use the ignore_warnings context manager.

>>> from sympy.utilities.exceptions import ignore_warnings
>>> from sympy.physics.mechanics import Body
>>> with ignore_warnings(DeprecationWarning):
...     A = Body('A')
>>> P = A.masscenter.locatenew('point', 3 * A.x + 5 * A.y)
>>> A.parallel_axis(P).to_matrix(A.frame)
Matrix([
[A_ixx + 25*A_mass, A_ixy - 15*A_mass,             A_izx],
[A_ixy - 15*A_mass,  A_iyy + 9*A_mass,             A_iyz],
[            A_izx,             A_iyz, A_izz + 34*A_mass]])

)r4   r   parallel_axisr	   )r#   rT   r    s      r/   rw   Body.parallel_axis  s4    N **4>>%%d599r1   )r!   r   r    r"   )NNNN)NNNr3   )__name__
__module____qualname____firstlineno____doc__r   r5   propertyr:   r=   rA   rD   r"   setterr4   rQ   rW   r`   rd   rh   rn   rq   rt   rw   __static_attributes__ r1   r/   r   r      s    dL @D!%1$f'
         7 7 ^^( (  
4Uln+`^1@80d$*L&,P*%X):r1   N)sympyr   sympy.physics.vectorr   r   r   r   sympy.physics.mechanicsr   r	   r
   !sympy.physics.mechanics.body_baser   sympy.utilities.exceptionsr   __all__r   r   r1   r/   <module>r      s1     F F @ @ 6 @(
z
:9h z
:r1   