Struct Body

Struct Documentation

struct Body

A celestial body used by environment and dynamics models.

A Body stores the body’s gravity parameter, reference radius, rotation rate, fixed/inertial frames, optional spherical-harmonic gravity field, and unit system. Factory methods create common solar-system bodies with SI units by default or with a caller-provided UnitSystem.

Public Members

BodyId id
std::string name
Real GM
Real R
Real omega
UnitSystem units = SI_UNITS
Frame fixed_frame
Frame inertial_frame
bool use_gravity_field
GravityField<Real> gravity_field

Public Static Functions

static Body Sun()

Create the Sun as a point-mass Body (no spherical-harmonic gravity field), in SI units.

Create a Body object for the Sun.

Returns:

Body object for the Sun

static Body Sun(const UnitSystem &units)

Vec3-units overload of Sun(): create the Sun in the requested unit system.

static Body Earth(int n = 0, int m = 0, std::string gravity_file = "EGM96.cof")

Create Earth as a Body, in SI units, optionally loading an nxm spherical-harmonic gravity field from gravity_file.

Create a Body object for the Earth.

Called by Body::CreateBody/NBodyDynamics::AddBody to assemble the central or perturbing-body list for NumericalOrbitDynamics; n/m set GravityField::n_max/m_max truncation used by AccelarationGravityField.

Parameters:
  • n – Max degree of the gravity field to load (0 disables the field, point-mass only)

  • m – Max order of the gravity field to load (0 disables the field, point-mass only)

  • gravity_file – Spherical-harmonic coefficient file name (default “EGM96.cof”)

Returns:

Earth Body with GM, R, omega, frames, and (if requested) gravity field populated

Returns:

Body object for the Earth

static Body Earth(const UnitSystem &units, int n = 0, int m = 0, std::string gravity_file = "EGM96.cof")

Unit-system overload of Earth(): create Earth in the requested unit system.

static Body Moon(int n = 0, int m = 0, std::string gravity_file = "grgm900c.cof")

Create the Moon as a Body, in SI units, optionally loading an nxm spherical-harmonic gravity field (default GRGM900C) from gravity_file.

Create a Body object for the Moon.

See Earth() for the role of the gravity-field parameters; used the same way by Body::CreateBody/NBodyDynamics::AddBody for Moon-centered or Moon-perturbation dynamics.

Returns:

Body object for the Moon

static Body Moon(const UnitSystem &units, int n = 0, int m = 0, std::string gravity_file = "grgm900c.cof")

Unit-system overload of Moon(): create the Moon in the requested unit system.

static Body Venus(int n = 0, int m = 0, std::string gravity_file = "MGN75HSAAP.cof")

Create Venus as a Body, in SI units, optionally loading an nxm spherical-harmonic gravity field (default MGN75HSAAP) from gravity_file.

Create a Body object for Venus.

Returns:

Body object for Venus

static Body Venus(const UnitSystem &units, int n = 0, int m = 0, std::string gravity_file = "MGN75HSAAP.cof")

Unit-system overload of Venus(): create Venus in the requested unit system.

static Body Mars(int n = 0, int m = 0, std::string gravity_file = "GMM1.cof")

Create Mars as a Body, in SI units, optionally loading an nxm spherical-harmonic gravity field (default GMM1) from gravity_file.

Create a Body object for Mars.

Returns:

Body object for Mars

static Body Mars(const UnitSystem &units, int n = 0, int m = 0, std::string gravity_file = "GMM1.cof")

Unit-system overload of Mars(): create Mars in the requested unit system.

static Body Jupiter()

Create Jupiter as a point-mass Body (no gravity field), in SI units.

static Body Jupiter(const UnitSystem &units)

Unit-system overload of Jupiter(): create Jupiter in the requested unit system.

static Body Saturn()

Create Saturn as a point-mass Body (no gravity field), in SI units.

static Body Saturn(const UnitSystem &units)

Unit-system overload of Saturn(): create Saturn in the requested unit system.

static Body Uranus()

Create Uranus as a point-mass Body (no gravity field), in SI units.

static Body Uranus(const UnitSystem &units)

Unit-system overload of Uranus(): create Uranus in the requested unit system.

static Body Neptune()

Create Neptune as a point-mass Body (no gravity field), in SI units.

static Body Neptune(const UnitSystem &units)

Unit-system overload of Neptune(): create Neptune in the requested unit system.

static Body CreateBody(BodyId body, int n = 0, int m = 0, std::string gravity_file = "")

Dispatch to the matching per-planet factory (Sun/Earth/Moon/…) based on body’s BodyId, in SI units.

Called by NBodyDynamics::AddBody (via Body::CreateBody(body_id, units_, n, / m, gravity_file)) to build each perturbing/central body listed in a dynamics-model config without per-body switch statements at the call site.

Parameters:
  • body – SPICE/LuPNT body identifier selecting which planet factory to call

  • n – Max degree of the gravity field to load (0 disables the field)

  • m – Max order of the gravity field to load (0 disables the field)

  • gravity_file – Spherical-harmonic coefficient file name (empty = use the per-body default)

Returns:

Body populated by the corresponding factory method

static Body CreateBody(BodyId body, const UnitSystem &units, int n = 0, int m = 0, std::string gravity_file = "")

Unit-system overload of CreateBody(): create a body from its identifier in the requested unit system.