intersection method

Bounds? intersection(
  1. Bounds other
)

Computes the intersection of this bounding box and another one.

Implementation

Bounds? intersection(Bounds other) {
  final result = Bounds(length);
  for (var i = 0; i < length; i++) {
    final lower = math.max(min[i], other.min[i]);
    final upper = math.min(max[i], other.max[i]);
    if (lower > upper) return null;
    result.min[i] = lower;
    result.max[i] = upper;
  }
  return result;
}