The vulcan::mass namespace provides a comprehensive MassProperties<Scalar> struct for modeling rigid body mass, center of gravity, and inertia tensors. It supports aggregation via operator overloading, making it easy to build up vehicle mass properties from components.
Key Features
- Factory constructors — Point mass, shapes (sphere, cylinder, box), full tensor
- Aggregation — Combine components with +, -, * operators
- Parallel axis theorem — Query inertia about any reference point
- Symbolic compatible — Works with casadi::MX for optimization
Frame Convention
All quantities are expressed in body-fixed coordinates:
| Field | Description |
| mass | Total mass [kg] |
| cg | CG position in body frame, from body origin [m] |
| inertia | Inertia tensor about CG, in body-fixed axes [kg·m²] |
Body Frame (typical aerospace convention):
X: Forward (out the nose)
Y: Right (starboard wing)
Z: Down
Quick Start
500.0,
0.5,
6.0,
Vec3<double>{3.0, 0.0, 0.0}
);
100.0, 0.5, 4.0, 0.1,
Vec3<double>{2.5, -2.5, 0}
);
100.0, 0.5, 4.0, 0.1,
Vec3<double>{2.5, 2.5, 0}
);
auto aircraft = fuselage + left_wing + right_wing;
std::cout <<
"Total mass: " << aircraft.
mass <<
" kg\n";
std::cout <<
"CG: [" << aircraft.
cg.transpose() <<
"] m\n";
Definition MassProperties.hpp:12
static MassProperties< Scalar > solid_box(const Scalar &m, const Scalar &dx, const Scalar &dy, const Scalar &dz, const Vec3< Scalar > &cg_pos=Vec3< Scalar >::Zero())
Definition MassProperties.hpp:184
Vec3< Scalar > cg
CG position in body frame [m].
Definition MassProperties.hpp:67
Scalar mass
Total mass [kg].
Definition MassProperties.hpp:66
static MassProperties< Scalar > solid_cylinder(const Scalar &m, const Scalar &radius, const Scalar &length, const Vec3< Scalar > &cg_pos=Vec3< Scalar >::Zero())
Definition MassProperties.hpp:163
Factory Constructors
Point Mass
static MassProperties< Scalar > point_mass(const Scalar &m, const Vec3< Scalar > &position)
Definition MassProperties.hpp:81
Solid Shapes
static MassProperties< Scalar > solid_sphere(const Scalar &m, const Scalar &radius, const Vec3< Scalar > &cg_pos=Vec3< Scalar >::Zero())
Definition MassProperties.hpp:147
Full Tensor
100.0,
Vec3<double>{1.0, 0.0, 0.0},
10.0, 20.0, 30.0,
1.0, 2.0, 3.0
);
static MassProperties< Scalar > from_components(const Scalar &m, const Vec3< Scalar > &cg_pos, const Scalar &Ixx, const Scalar &Iyy, const Scalar &Izz, const Scalar &Ixy, const Scalar &Ixz, const Scalar &Iyz)
Definition MassProperties.hpp:119
Aggregation
Mass properties combine using the parallel axis theorem:
auto total = wing + fuse + tail;
auto drilled = solid - hole;
auto half = total * 0.5;
Vector Aggregation
std::vector<MassProperties<double>> tanks = {
};
MassProperties< Scalar > aggregate_mass_properties(const std::vector< MassProperties< Scalar > > &components)
Definition MassProperties.hpp:347
Parallel Axis Theorem
Query inertia about any point (not just CG):
auto I_origin = sphere.inertia_about_point(Vec3<double>::Zero());
Variable Mass
Mass properties are passed as input to dynamics functions, enabling variable mass:
for (double t = 0; t < t_final; t += dt) {
double current_mass = dry_mass + fuel_mass - burn_rate * t;
auto vehicle = dry + fuel;
auto derivs = compute_6dof_derivatives(state, F, M, vehicle);
}
Symbolic Usage
All operations work with casadi::MX for trajectory optimization:
using MX = casadi::MX;
auto m1 = janus::sym("m1");
auto x1 = janus::sym("x1");
auto combined = mp1 + mp2;
janus::Function
f(
"aggregate", {m1, m2, x1, x2}, {combined.
mass, combined.
cg(0)});
constexpr double f
Flattening (WGS84).
Definition Constants.hpp:25
Validation (Numeric Only)
Mat3< Scalar > principal_axes(const MassProperties< Scalar > &props)
Compute principal axes rotation matrix (eigenvectors, numeric only).
Definition MassProperties.hpp:441
bool is_physically_valid(const MassProperties< Scalar > &props)
Definition MassProperties.hpp:396
bool is_point_mass(const MassProperties< Scalar > &props)
Check if effectively a point mass (zero inertia).
Definition MassProperties.hpp:424
Vec3< Scalar > principal_moments(const MassProperties< Scalar > &props)
Compute principal moments of inertia (eigenvalues, numeric only).
Definition MassProperties.hpp:432
See Also