unionAll static method

Bounds unionAll(
  1. Iterable<Bounds> bounds
)

Computes the union of all bounding boxes.

Implementation

static Bounds unionAll(Iterable<Bounds> bounds) {
  final iterator = bounds.iterator;
  if (!iterator.moveNext()) throw StateError('Empty bounds: $bounds');
  final result = Bounds.fromLists(iterator.current.min, iterator.current.max);
  while (iterator.moveNext()) {
    final current = iterator.current;
    for (var i = 0; i < result.length; i++) {
      result.min[i] = math.min(result.min[i], current.min[i]);
      result.max[i] = math.max(result.max[i], current.max[i]);
    }
  }
  return result;
}