sphereOverlapsAabb function Physics
Whether the closed ball at center of radius overlaps the AABB
box.
Implementation
bool sphereOverlapsAabb(Vector3 center, double radius, Aabb3 box) {
final cx = _clamp(center.x, box.min.x, box.max.x);
final cy = _clamp(center.y, box.min.y, box.max.y);
final cz = _clamp(center.z, box.min.z, box.max.z);
final dx = center.x - cx;
final dy = center.y - cy;
final dz = center.z - cz;
return dx * dx + dy * dy + dz * dz <= radius * radius;
}