Checking whether two rectangles intersect is a common problem in computer graphics and computational geometry. It is often used to determine whether two objects are colliding, or to calculate the overlapping area between two shapes. There are several different algorithms for checking rectangle intersection, each with its own advantages and disadvantages.
One of the most common algorithms is the axis-aligned bounding box (AABB) algorithm. This algorithm checks whether the two rectangles’ AABBs intersect. The AABB of a rectangle is the smallest rectangle that completely contains the original rectangle. If the two AABBs intersect, then the original rectangles must also intersect.