intersectsWithSphere method

bool intersectsWithSphere (Sphere other)

Return if this intersects with other.

Implementation

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

  for (int 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;
}