Struct UnitSystem

Struct Documentation

struct UnitSystem

Coherent simulation unit system used to scale SI constants.

Each field stores the number of SI base units in one simulation unit. For example, KM_S_KG_UNITS.length == 1000.0, so a quantity expressed in meters is divided by 1000 when converted to simulation length units.

Public Functions

inline double FromSI(double value, int length_power, int time_power = 0, int mass_power = 0) const

Convert an SI value into this unit system using dimensional powers.

Called by the per-quantity helpers below (Length, Velocity, GravitationalParameter, etc.) and by GetPhysicalConstants(units) to rescale every SI-valued physical constant into a simulation’s chosen unit system (e.g. KM_S_KG_UNITS) before propagation.

Parameters:
  • value – Value in SI units

  • length_power – Exponent of length in the quantity’s dimension

  • time_power – Exponent of time in the quantity’s dimension

  • mass_power – Exponent of mass in the quantity’s dimension

Returns:

Value expressed in this unit system

inline double ToSI(double value, int length_power, int time_power = 0, int mass_power = 0) const

Convert a value expressed in this unit system back into SI units.

Inverse of FromSI; used wherever a quantity stored in a simulation’s working unit system needs to be reported or compared in SI units.

Parameters:
  • value – Value in this unit system

  • length_power – Exponent of length in the quantity’s dimension

  • time_power – Exponent of time in the quantity’s dimension

  • mass_power – Exponent of mass in the quantity’s dimension

Returns:

Value in SI units

inline double Length(double value_m) const

Convert a length [m] into this unit system.

inline double Area(double value_m2) const

Convert an area [m^2] into this unit system.

inline double Volume(double value_m3) const

Convert a volume [m^3] into this unit system.

inline double Duration(double value_s) const

Convert a duration [s] into this unit system.

inline double Mass(double value_kg) const

Convert a mass [kg] into this unit system.

inline double Velocity(double value_m_s) const

Convert a velocity [m/s] into this unit system.

inline double Acceleration(double value_m_s2) const

Convert an acceleration [m/s^2] into this unit system.

inline double GravitationalParameter(double value_m3_s2) const

Convert a gravitational parameter GM [m^3/s^2] into this unit system.

inline double AngularVelocity(double value_rad_s) const

Convert an angular velocity [rad/s] into this unit system.

inline double Frequency(double value_hz) const

Convert a frequency [Hz] into this unit system.

inline double Force(double value_n) const

Convert a force [N] into this unit system.

inline double Pressure(double value_pa) const

Convert a pressure [Pa] into this unit system.

inline double AreaPerMass(double value_m2_kg) const

Convert an area-to-mass ratio [m^2/kg] into this unit system (e.g. for SRP area-to-mass terms).

inline bool operator==(const UnitSystem &other) const

True if both unit systems use the same length, time, and mass scales.

inline bool operator!=(const UnitSystem &other) const

True if the unit systems differ in any of length, time, or mass scale.

Public Members

double length = METER
double time = SECOND
double mass = KILOGRAM