intersectsWithSphere method

bool intersectsWithSphere(
  1. Sphere other
)

Return if this intersects with other.

Implementation

bool intersectsWithSphere(Sphere other) {
  final center = other._center;
  final radius = other.radius;
  var d = 0.0;
  var e = 0.0;

  for (var i = 0; i < 3; ++i) {
    if ((e = center[i] - _min[i]) < 0.0) {
      if (e < -radius) {
        return false;
      }

      d = d + e * e;
    } else {
      if ((e = center[i] - _max[i]) > 0.0) {
        if (e > radius) {
          return false;
        }

        d = d + e * e;
      }
    }
  }

  return d <= radius * radius;
}