intersectionWithAabb2 method

Rect intersectionWithAabb2(
  1. Aabb2 other
)

Creates a Rect of the area that this and other both cover.

The Rect has a negative width or height if the boxes don't overlap.

Implementation

Rect intersectionWithAabb2(Aabb2 other) {
  final otherMin = other.min;
  final otherMax = other.max;
  return Rect.fromLTRB(
    math.max(min.x, otherMin.x),
    math.max(min.y, otherMin.y),
    math.min(max.x, otherMax.x),
    math.min(max.y, otherMax.y),
  );
}