c4dynamics.eqm.derivs.eqm6#
- c4dynamics.eqm.derivs.eqm6(rb: rigidbody, F: ndarray | list, M: ndarray | list) ndarray [source]#
Translational and angular motion derivatives.
A set of first-order ordinary differential equations (ODEs) that describe the motion of a rigid body in three-dimensional space under the influence of external forces and moments.
- Parameters:
rb (
rigidbody
) – C4dynamics’ rigidbody object for which the equations of motion are calculated on.F (array_like) – Force vector \([F_x, F_y, F_z]\)
M (array_like) – Moments vector \([M_x, M_y, M_z]\)
- Returns:
out (numpy.array) – \([dx, dy, dz, dv_x, dv_y, dv_z, d\varphi, d\theta, d\psi, dp, dq, dr]\)
12 total derivatives; 6 of translational motion, 6 of rotational motion.
Examples
Euler integration on the equations of motion of a stick fixed at one edge:
(mass: 0.5 kg, moment of inertia about y: 0.4 kg*m^2, Length: 1m, initial Euler pitch angle: 80° (converted to radians))
Import required packages:
>>> import c4dynamics as c4d >>> import numpy as np
Settings and initial conditions
>>> dt = 0.5e-3 >>> t = np.arange(0, 10, dt) >>> length = 1 # metter >>> rb = c4d.rigidbody(theta = 80 * c4d.d2r) >>> rb.mass = 0.5 # kg >>> rb.I = [0, 0.4, 0]
Main loop:
>>> for ti in t: ... rb.store(ti) ... tau_g = -rb.mass * c4d.g_ms2 * length / 2 * c4d.cos(rb.theta) ... dx = c4d.eqm.eqm6(rb, np.zeros(3), [0, tau_g, 0]) ... rb.X += dx * dt >>> rb.plot('theta')