K i/(pddlmZmZddlmZmZmZmZddlm Z ddl m Z m Z ddl mZdgZGdde Zy) )SymbolS)ReferenceFrameDyadicPointdot)BodyBase)inertia_of_point_massInertia)sympy_deprecation_warning RigidBodyceZdZdZ dfd ZdZedZejdZedZ edZ edZ ed Z e jd Z ed Z e jd Z d ZdZdZdZddZxZS)r aAn 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 pt |||||t|d}||_|t |d}t |d}t |d}t |d} t |d} t |d} t j |j|j|||| | | }||_y)N_frame_ixx_iyy_izz_izx_ixy_iyz) super__init__rframerr from_inertia_scalars masscenterinertia) selfnamerrmassrixxiyyizzizxixyiyz __class__s g/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/physics/mechanics/rigidbody.pyrzRigidBody.__init__9s z40 ="dV6?3E ?D6'CD6'CD6'CD6'CD6'CD6'C224??DJJ36S#sCQG c |jjdt|jdt|jdt|j dt|j dt|jd S)N(z , masscenter=z, frame=z, mass=z , inertia=))r&__name__reprrrrrrrs r'__repr__zRigidBody.__repr__Jsp>>**+1T$))_,=]()$tzz2B1C7 ?#:d4<<.@-AD Er(c|jS)z%The ReferenceFrame fixed to the body.)rr.s r'rzRigidBody.frameOs{{r(cHt|ts td||_y)Nz0RigidBody frame must be a ReferenceFrame object.) isinstancer TypeErrorr)rFs r'rzRigidBody.frameTs!^,NO O r(c.|jjS)z3The basis Vector for the body, in the x direction. )rxr.s r'r6z RigidBody.xZzz||r(c.|jjS)z3The basis Vector for the body, in the y direction. )ryr.s r'r9z RigidBody.y_r7r(c.|jjS)z3The basis Vector for the body, in the z direction. )rzr.s r'r;z RigidBody.zdr7r(c|jS)zRigidBody inertia must be a tuple of the form (Dyadic, Point).) lenr2rrr3r r=r rrpos_fromr_central_inertia)rII_Ss_Os r'rzRigidBody.inertians q6Q;j1v6j1u>U\] ]!ad+ 'tyy'+'?'?!'E'+zz3!"!v r(c|jS)z"The body's central inertia dyadic.)rCr.s r'central_inertiazRigidBody.central_inertia}s$$$r(cpt|ts tdt||j|_y)Nz*RigidBody inertia must be a Dyadic object.)r2rr3r rr)rrDs r'rGzRigidBody.central_inertias*!V$HI Iq$//2 r(cR|j|jj|zS)a! 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 )rrvel)rrs r'linear_momentumzRigidBody.linear_momentums#Nyy4??..u555r(c |j}|jj|}|j}|jj |}|jj |}|j||j||zzS)aReturns 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 ) rGr ang_vel_inrrrBrJrcross)rpointrrDwmrvs r'angular_momentumzRigidBody.angular_momentumstX   JJ ! !% ( II OO $ $U + OO   &uuQx!''!a%.((r(c tjt|jj |t|j |jj |z}tj|j zt|jj||jj|z}||zS)a[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 ) rHalfrrrMrGrrrJ)rr rotational_KEtranslational_KEs r'kinetic_energyzRigidBody.kinetic_energysV JJ ! !% ( $$djj&;&;E&B C"EE 66DII-DOO4G4G4N48OO4G4G4N1PP///r(c.tddd||_y)Nz The sympy.physics.mechanics.RigidBody.set_potential_energy() method is deprecated. Instead use B.potential_energy = scalar z1.5zdeprecated-set-potential-energy)deprecated_since_versionactive_deprecations_target)r potential_energy)rscalars r'set_potential_energyzRigidBody.set_potential_energys!!  "'#D !'r(c| |j}|jt|j|jj ||zS)aReturns 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. )rrGr rrrB)rrOrs r' parallel_axiszRigidBody.parallel_axis$sG& =JJE##&; IIt//6'?? ?r()NNNN)N)r, __module__ __qualname____doc__rr/propertyrsetterr6r9r;rrGrKrTrYr_ra __classcell__)r&s@r'r r s,\@D"E  \\  ^^ . .%%33 '6R2)h00d '?r(N)sympyrrsympy.physics.vectorrrrr!sympy.physics.mechanics.body_baser sympy.physics.mechanics.inertiar r sympy.utilities.exceptionsr __all__r r(r'ros,CC6J@ -p?p?r(