
    \h/(                     p    S SK JrJr  S SKJrJrJrJr  S SKJ	r	  S SK
JrJr  S SKJr  S/r " S S\	5      rg)	    )SymbolS)ReferenceFrameDyadicPointdot)BodyBase)inertia_of_point_massInertia)sympy_deprecation_warning	RigidBodyc                   (  ^  \ rS rSrSr  SU 4S jjrS r\S 5       r\R                  S 5       r\S 5       r
\S 5       r\S	 5       r\S
 5       r\R                  S 5       r\S 5       r\R                  S 5       rS rS rS rS rSS jrSrU =r$ )r   
   as  An idealized rigid body.

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

This is essentially a container which holds the various components which
describe a rigid body: a name, mass, center of mass, reference frame, and
inertia.

All of these need to be supplied on creation, but can be changed
afterwards.

Attributes
==========

name : string
    The body's name.
masscenter : Point
    The point which represents the center of mass of the rigid body.
frame : ReferenceFrame
    The ReferenceFrame which the rigid body is fixed in.
mass : Sympifyable
    The body's mass.
inertia : (Dyadic, Point)
    The body's inertia about a point; stored in a tuple as shown above.
potential_energy : Sympifyable
    The potential energy of the RigidBody.

Examples
========

>>> from sympy import Symbol
>>> from sympy.physics.mechanics import ReferenceFrame, Point, RigidBody
>>> from sympy.physics.mechanics import outer
>>> m = Symbol('m')
>>> A = ReferenceFrame('A')
>>> P = Point('P')
>>> I = outer (A.x, A.x)
>>> inertia_tuple = (I, P)
>>> B = RigidBody('B', P, A, m, inertia_tuple)
>>> # Or you could change them afterwards
>>> m2 = Symbol('m2')
>>> B.mass = m2

c           
      j  > [         TU ]  XU5        Uc  [        U S35      nX0l        Uc  [	        U S35      n[	        U S35      n[	        U S35      n[	        U S35      n	[	        U S35      n
[	        U S35      n[
        R                  " U R                  U R                  XgXX5      nXPl        g )N_frame_ixx_iyy_izz_izx_ixy_iyz)	super__init__r   framer   r   from_inertia_scalars
masscenterinertia)selfnamer   r   massr   ixxiyyizzizxixyiyz	__class__s               Y/var/www/auris/envauris/lib/python3.13/site-packages/sympy/physics/mechanics/rigidbody.pyr   RigidBody.__init__9   s    40="dV6?3E
?D6'CD6'CD6'CD6'CD6'CD6'C224??DJJ36SsQG    c                    U R                   R                   S[        U R                  5       S[        U R                  5       S[        U R
                  5       S[        U R                  5       S[        U R                  5       S3$ )N(z, masscenter=z, frame=z, mass=z
, inertia=))r'   __name__reprr   r   r   r    r   r   s    r(   __repr__RigidBody.__repr__J   sp    >>**+1T$))_,=]()$tzz2B1C7		?#:d4<<.@-AD 	Er*   c                     U R                   $ )z%The ReferenceFrame fixed to the body.)r   r0   s    r(   r   RigidBody.frameO   s     {{r*   c                 P    [        U[        5      (       d  [        S5      eXl        g )Nz0RigidBody frame must be a ReferenceFrame object.)
isinstancer   	TypeErrorr   )r   Fs     r(   r   r4   T   s     !^,,NOOr*   c                 .    U R                   R                  $ )z3The basis Vector for the body, in the x direction. )r   xr0   s    r(   r:   RigidBody.xZ        zz||r*   c                 .    U R                   R                  $ )z3The basis Vector for the body, in the y direction. )r   yr0   s    r(   r>   RigidBody.y_   r<   r*   c                 .    U R                   R                  $ )z3The basis Vector for the body, in the z direction. )r   zr0   s    r(   rA   RigidBody.zd   r<   r*   c                     U R                   $ )z<The body's inertia about a point; stored as (Dyadic, Point).)_inertiar0   s    r(   r   RigidBody.inertiai   s     }}r*   c                 Z   [        U5      S:w  d0  [        US   [        5      (       a  [        US   [        5      (       d  [	        S5      e[        US   US   5      U l        [        U R                  U R                  R                  US   5      U R                  5      nUS   U-
  U l        g )N   r      z>RigidBody inertia must be a tuple of the form (Dyadic, Point).)lenr6   r   r   r7   r   rD   r
   r    r   pos_fromr   _central_inertia)r   II_Ss_Os      r(   r   rE   n   s     q6Q;j1v66j1u>U>U\]]!ad+ 'tyy'+'?'?!'E'+zz3 !"!vr*   c                     U R                   $ )z"The body's central inertia dyadic.)rK   r0   s    r(   central_inertiaRigidBody.central_inertia}   s     $$$r*   c                 x    [        U[        5      (       d  [        S5      e[        XR                  5      U l        g )Nz*RigidBody inertia must be a Dyadic object.)r6   r   r7   r   r   r   )r   rL   s     r(   rO   rP      s+    !V$$HIIq//2r*   c                 R    U R                   U R                  R                  U5      -  $ )aH  Linear momentum of the rigid body.

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

The linear momentum L, of a rigid body B, with respect to frame N is
given by:

``L = m * v``

where m is the mass of the rigid body, and v is the velocity of the mass
center of B in the frame N.

Parameters
==========

frame : ReferenceFrame
    The frame in which linear momentum is desired.

Examples
========

>>> from sympy.physics.mechanics import Point, ReferenceFrame, outer
>>> from sympy.physics.mechanics import RigidBody, dynamicsymbols
>>> from sympy.physics.vector import init_vprinting
>>> init_vprinting(pretty_print=False)
>>> m, v = dynamicsymbols('m v')
>>> N = ReferenceFrame('N')
>>> P = Point('P')
>>> P.set_vel(N, v * N.x)
>>> I = outer (N.x, N.x)
>>> Inertia_tuple = (I, P)
>>> B = RigidBody('B', P, N, m, Inertia_tuple)
>>> B.linear_momentum(N)
m*v*N.x

)r    r   vel)r   r   s     r(   linear_momentumRigidBody.linear_momentum   s#    N yy4??..u555r*   c                    U R                   nU R                  R                  U5      nU R                  nU R                  R                  U5      nU R                  R                  U5      nUR                  U5      UR                  XW-  5      -   $ )a  Returns the angular momentum of the rigid body about a point in the
given frame.

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

The angular momentum H of a rigid body B about some point O in a frame N
is given by:

``H = dot(I, w) + cross(r, m * v)``

where I and m are the central inertia dyadic and mass of rigid body B, w
is the angular velocity of body B in the frame N, r is the position
vector from point O to the mass center of B, and v is the velocity of
the mass center in the frame N.

Parameters
==========

point : Point
    The point about which angular momentum is desired.
frame : ReferenceFrame
    The frame in which angular momentum is desired.

Examples
========

>>> from sympy.physics.mechanics import Point, ReferenceFrame, outer
>>> from sympy.physics.mechanics import RigidBody, dynamicsymbols
>>> from sympy.physics.vector import init_vprinting
>>> init_vprinting(pretty_print=False)
>>> m, v, r, omega = dynamicsymbols('m v r omega')
>>> N = ReferenceFrame('N')
>>> b = ReferenceFrame('b')
>>> b.set_ang_vel(N, omega * b.x)
>>> P = Point('P')
>>> P.set_vel(N, 1 * N.x)
>>> I = outer(b.x, b.x)
>>> B = RigidBody('B', P, b, m, (I, P))
>>> B.angular_momentum(P, N)
omega*b.x

)	rO   r   
ang_vel_inr    r   rJ   rS   r   cross)r   pointr   rL   wmrvs           r(   angular_momentumRigidBody.angular_momentum   sr    X   JJ!!%(IIOO$$U+OO&uuQx!''!%.((r*   c           
         [         R                  [        U R                  R	                  U5      [        U R
                  U R                  R	                  U5      5      5      -  n[         R                  U R                  -  [        U R                  R                  U5      U R                  R                  U5      5      -  nX#-   $ )ac  Kinetic energy of the rigid body.

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

The kinetic energy, T, of a rigid body, B, is given by:

``T = 1/2 * (dot(dot(I, w), w) + dot(m * v, v))``

where I and m are the central inertia dyadic and mass of rigid body B
respectively, w is the body's angular velocity, and v is the velocity of
the body's mass center in the supplied ReferenceFrame.

Parameters
==========

frame : ReferenceFrame
    The RigidBody'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
========

>>> from sympy.physics.mechanics import Point, ReferenceFrame, outer
>>> from sympy.physics.mechanics import RigidBody
>>> from sympy import symbols
>>> m, v, r, omega = symbols('m v r omega')
>>> N = ReferenceFrame('N')
>>> b = ReferenceFrame('b')
>>> b.set_ang_vel(N, omega * b.x)
>>> P = Point('P')
>>> P.set_vel(N, v * N.x)
>>> I = outer (b.x, b.x)
>>> inertia_tuple = (I, P)
>>> B = RigidBody('B', P, b, m, inertia_tuple)
>>> B.kinetic_energy(N)
m*v**2/2 + omega**2/2

)	r   Halfr   r   rW   rO   r    r   rS   )r   r   rotational_KEtranslational_KEs       r(   kinetic_energyRigidBody.kinetic_energy   s    V JJ!!%($$djj&;&;E&BC"E E 66DII-DOO4G4G4N48OO4G4G4N1P P//r*   c                 &    [        SSSS9  Xl        g )Nz
The sympy.physics.mechanics.RigidBody.set_potential_energy()
method is deprecated. Instead use

    B.potential_energy = scalar
            z1.5zdeprecated-set-potential-energy)deprecated_since_versionactive_deprecations_target)r   potential_energy)r   scalars     r(   set_potential_energyRigidBody.set_potential_energy  s    ! "'#D		
 !'r*   c                     Uc  U R                   nU R                  [        U R                  U R                  R                  U5      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.

)r   rO   r
   r    r   rJ   )r   rY   r   s      r(   parallel_axisRigidBody.parallel_axis$  sG    & =JJE##&;IIt//6'? ? 	?r*   )rK   r   rD   r   r   ri   )NNNN)N)r.   
__module____qualname____firstlineno____doc__r   r1   propertyr   setterr:   r>   rA   r   rO   rT   r^   rd   rk   rn   __static_attributes____classcell__)r'   s   @r(   r   r   
   s   ,\ @D"E
   \\ 
         ^^. . % % 3 3
'6R2)h00d'? ?r*   N)sympyr   r   sympy.physics.vectorr   r   r   r   !sympy.physics.mechanics.body_baser	   sympy.physics.mechanics.inertiar
   r   sympy.utilities.exceptionsr   __all__r    r*   r(   <module>r      s,     C C 6 J @-p? p?r*   