K i rddlmZddlmZmZmZmZddlmZgdZ d dZ dZ Gddedd d gZ y ) )sympify)PointDyadicReferenceFrameouter) namedtuple)inertiainertia_of_point_massInertiacBt|ts tdt|t|t|}}}t|t|t|}}}|t |j |j z|t |j |j zz|t |j |jzz|t |j |j zz|t |j |j zz|t |j |jzz|t |j|j zz|t |j|j zz|t |j|jzzS)a~Simple way to create inertia Dyadic object. Explanation =========== Creates an inertia Dyadic based on the given tensor values and a body-fixed reference frame. Parameters ========== frame : ReferenceFrame The frame the inertia is defined in. ixx : Sympifyable The xx element in the inertia dyadic. iyy : Sympifyable The yy element in the inertia dyadic. izz : Sympifyable The zz element in the inertia dyadic. ixy : Sympifyable The xy element in the inertia dyadic. iyz : Sympifyable The yz element in the inertia dyadic. izx : Sympifyable The zx element in the inertia dyadic. Examples ======== >>> from sympy.physics.mechanics import ReferenceFrame, inertia >>> N = ReferenceFrame('N') >>> inertia(N, 1, 2, 3) (N.x|N.x) + 2*(N.y|N.y) + 3*(N.z|N.z) z%Need to define the inertia in a frame) isinstancer TypeErrorrrxyz)frameixxiyyizzixyiyzizxs e/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/physics/mechanics/inertia.pyr r sOJ e^ ,?@@CL'#, cCCL'#, cC egguww' '#eEGGUWW.E*E E egguww' ' (*-eEGGUWW.E*E F egguww' ' (*-eEGGUWW.E*E F egguww' ' (+.eEGGUWW.E*E F egguww' '  ()c |t|j|jt|j|jzt|j|jz|j |zt||z zS)aOInertia dyadic of a point mass relative to point O. Parameters ========== mass : Sympifyable Mass of the point mass pos_vec : Vector Position from point O to point mass frame : ReferenceFrame Reference frame to express the dyadic in Examples ======== >>> from sympy import symbols >>> from sympy.physics.mechanics import ReferenceFrame, inertia_of_point_mass >>> N = ReferenceFrame('N') >>> r, m = symbols('r m') >>> px = r * N.x >>> inertia_of_point_mass(m, px, N) m*r**2*(N.y|N.y) + m*r**2*(N.z|N.z) )rrrrdot)masspos_vecrs rr r 8su4  uww uww  ! uww  ! W  "'w!8 9 ::rcPeZdZdZdZfdZe ddZdZdZ eZ e Z xZ S)r ayInertia object consisting of a Dyadic and a Point of reference. Explanation =========== This is a simple class to store the Point and Dyadic, belonging to an inertia. Attributes ========== dyadic : Dyadic The dyadic of the inertia. point : Point The reference point of the inertia. Examples ======== >>> from sympy.physics.mechanics import ReferenceFrame, Point, Inertia >>> N = ReferenceFrame('N') >>> Po = Point('Po') >>> Inertia(N.x.outer(N.x) + N.y.outer(N.y) + N.z.outer(N.z), Po) ((N.x|N.x) + (N.y|N.y) + (N.z|N.z), Po) In the example above the Dyadic was created manually, one can however also use the ``inertia`` function for this or the class method ``from_tensor`` as shown below. >>> Inertia.from_inertia_scalars(Po, N, 1, 1, 1) ((N.x|N.x) + (N.y|N.y) + (N.z|N.z), Po) ct|trt|tr||}}t|ts tdt|ts tdt||||S)Nz'Reference point should be of type Pointz-Inertia value should be expressed as a Dyadic)r rrrsuper__new__)clsdyadicpoint __class__s rr#zInertia.__new__}s^ fe $E6)B"E6E%'EF F&&)KL LwsFE22rc 2|t||||||||S)aSimple way to create an Inertia object based on the tensor values. Explanation =========== This class method uses the :func`~.inertia` to create the Dyadic based on the tensor values. Parameters ========== point : Point The reference point of the inertia. frame : ReferenceFrame The frame the inertia is defined in. ixx : Sympifyable The xx element in the inertia dyadic. iyy : Sympifyable The yy element in the inertia dyadic. izz : Sympifyable The zz element in the inertia dyadic. ixy : Sympifyable The xy element in the inertia dyadic. iyz : Sympifyable The yz element in the inertia dyadic. izx : Sympifyable The zx element in the inertia dyadic. Examples ======== >>> from sympy import symbols >>> from sympy.physics.mechanics import ReferenceFrame, Point, Inertia >>> ixx, iyy, izz, ixy, iyz, izx = symbols('ixx iyy izz ixy iyz izx') >>> N = ReferenceFrame('N') >>> P = Point('P') >>> I = Inertia.from_inertia_scalars(P, N, ixx, iyy, izz, ixy, iyz, izx) The tensor values can easily be seen when converting the dyadic to a matrix. >>> I.dyadic.to_matrix(N) Matrix([ [ixx, ixy, izx], [ixy, iyy, iyz], [izx, iyz, izz]]) )r ) r$r&rrrrrrrs rfrom_inertia_scalarszInertia.from_inertia_scalarss#f75#sCc3?GGrcvtd|jjd|jjd)Nz$unsupported operand type(s) for +: '' and ''rr'__name__selfothers r__add__zInertia.__add__@ NN3345!OO445Q89 9rcvtd|jjd|jjd)Nz$unsupported operand type(s) for *: 'r+r,r-r/s r__mul__zInertia.__mul__r3rrrr) r. __module__ __qualname____doc__ __slots__r# classmethodr)r2r5__radd____rmul__ __classcell__)r's@rr r YsH BI3JK!"2H2Hh9 9 HHrr r%r&Nr6) sympyrsympy.physics.vectorrrrr collectionsr__all__r r r r rrrCs<EE" 9-)`:BnjXw$78nr