getAxisAlignedBoundingBox static method

  1. @visibleForTesting
Quad getAxisAlignedBoundingBox(
  1. Quad quad
)

Given a quad, return its axis aligned bounding box.

Implementation

@visibleForTesting
static Quad getAxisAlignedBoundingBox(Quad quad) {
  final double minX = math.min(
    quad.point0.x,
    math.min(
      quad.point1.x,
      math.min(
        quad.point2.x,
        quad.point3.x,
      ),
    ),
  );
  final double minY = math.min(
    quad.point0.y,
    math.min(
      quad.point1.y,
      math.min(
        quad.point2.y,
        quad.point3.y,
      ),
    ),
  );
  final double maxX = math.max(
    quad.point0.x,
    math.max(
      quad.point1.x,
      math.max(
        quad.point2.x,
        quad.point3.x,
      ),
    ),
  );
  final double maxY = math.max(
    quad.point0.y,
    math.max(
      quad.point1.y,
      math.max(
        quad.point2.y,
        quad.point3.y,
      ),
    ),
  );
  return Quad.points(
    Vector3(minX, minY, 0),
    Vector3(maxX, minY, 0),
    Vector3(maxX, maxY, 0),
    Vector3(minX, maxY, 0),
  );
}