calculateLocalInertia method

  1. @override
Vec3 calculateLocalInertia(
  1. double mass,
  2. Vec3 target
)
override

@return The "target" vector object

Implementation

@override
Vec3 calculateLocalInertia(double mass, Vec3 target) {
  // Approximate with box inertia
  // Exact inertia calculation is overkill, but see http://geometrictools.com/Documentation/PolyhedralMassProperties.pdf for the correct way to do it
  computeLocalAABB(_cliAabb);
  final x = _cliAabb.upperBound.x - _cliAabb.lowerBound.x;
  final y = _cliAabb.upperBound.y - _cliAabb.lowerBound.y;
  final z = _cliAabb.upperBound.z - _cliAabb.lowerBound.z;
  return target.set(
    1.0 / 12.0 * mass * (2*y*2*y + 2*z*2*z),
    1.0 / 12.0 * mass * (2*x*2*x + 2*z*2*z),
    1.0 / 12.0 * mass * (2*y*2*y + 2*x*2*x)
  );
}