flexible-collision-library / fcl

Flexible Collision Library
https://flexible-collision-library.github.io/
Other
1.39k stars 417 forks source link

CollisionGeometry::computeMomentofInertiaRelatedToCOM #327

Open SeanCurtis-TRI opened 6 years ago

SeanCurtis-TRI commented 6 years ago

The CollisionGeometry::computeMOmentofInertiaRelatedToCOM is naively implemented. It explicitly calls the virtual methods to compute moment of inertia, center of mass, and volume. For simple primitive shapes where these quantities are O(1) operations that's not bad. But for meshes this is horrible. These quantities are so tightly coupled that it makes sense to have the option to compute them simultaneously (to reduce the cost of the integrals).

I propose that the CollisionGeometry class be given a new virtual method:

/// Compute the volume of the geometry while simultaneously reporting the center of mass and the inertial tensor in the world frame (returned in the given out parameters).
virtual S computeMassProperties(Matrix3<S>* inertia_tensor, Vector3<S>* com)

It's default implementation can be exactly those three calls currently being made, so most geometry sub-classes can ignore it. But more complex geometries can override it and solve for all three quantities simultaneously.

sherm1 commented 6 years ago

Great idea!