rec1 is to the left of rec2 by comparing if rec1[2] (right side of rec1) is less than or equal to rec2[0] (left side of rec2).rec1 is to the right of rec2 by comparing if rec1[0] (left side of rec1) is greater than or equal to rec2[2] (right side of rec2).rec1 is above rec2 by comparing if rec1[1] (bottom side of rec1) is greater than or equal to rec2[3] (top side of rec2).rec1 is below rec2 by comparing if rec1[3] (top side of rec1) is less than or equal to rec2[1] (bottom side of rec2).rec1 is to the left, right, above, or below rec2, then the rectangles overlap.