operator + method

BoundingBox operator +(
  1. BoundingBox other
)

Implementation

BoundingBox operator +(BoundingBox other) {
  double x = this.x < other.x ? this.x : other.x;
  double y = this.y < other.y ? this.y : other.y;
  double width = (this.x + this.width) > (other.x + other.width)
      ? (this.x + this.width) - x
      : (other.x + other.width) - x;
  double height = (this.y + this.height) > (other.y + other.height)
      ? (this.y + this.height) - y
      : (other.y + other.height) - y;
  return BoundingBox(x, y, width, height);
}