Body

Module for handling a spherical moving body.

module:

body

author:

Le Bars, Yoann

This file is part of the pure Python benchmark.

This Python benchmark is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This Python benchmark is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

The file LICENSE is a copy of the GNU General Public License. You can also see it on https://www.gnu.org/licenses/.

class body.Body(m: float, r: float, x0: ndarray, v0: ndarray, a0: ndarray, alpha0: ndarray)

Class for handling moving bodies.

Parameters:
  • m (float) – Body mass (in kg).

  • r (float) – Body radius (in m).

  • I (np.ndarray) – Inverse of body inertia momentum tensor (in kg⋅m²).

  • x (np.ndarray) – Body position vector (in m).

  • v (np.ndarray) – Body velocity vector (in km/s).

  • a (np.ndarray) – Body acceleration vector (in m/s²).

  • pre_a (np.ndarray) – Body previous acceleration vector (in m/s²).

  • q (Rotation) – Body orientation as a unit quaternion.

  • alpha (np.ndarray) – Body angular acceleration vector (in rad/s²).

  • pre_alpha (np.ndarray) – Body previous angular acceleration vector (in rad/s²).

add_to_omega(delta_omega: ndarray) None

Adds to the current angular velocity vector.

add_to_v(delta_v: ndarray) None

Adds to the current velocity vector.

prepare_for_step() None

Prepares for the next integration step.

update_position(dt: float) None

Updates position based on Verlet integration.

Parameters:

dt (float) – Time step (in s).

update_rotation(dt: float) None

Updates rotation and angular velocity.

Parameters:

dt (float) – Time step (in s).

update_velocity(dt: float) None

Updates velocity based on Verlet integration.

Parameters:

dt (float) – Time step (in s).