public bool IsAnyOfTheCornerPointsWithIn(OverlappingRectangle other) { var isBottomLeftWithIn = IsPointWith(other, MinX, MinY); var isBottomRightWithIn = IsPointWith(other, MaxX, MinY); var isTopLeftWithIn = IsPointWith(other, MinX, MaxY); var isTopRightWithIn = IsPointWith(other, MaxX, MaxY); return isBottomLeftWithIn || isBottomRightWithIn || isTopLeftWithIn || isTopRightWithIn; }
private static bool IsPointWith(OverlappingRectangle other, int x, int y) { return x >= other.MinX && x <= other.MaxX && y >= other.MinY && y <= other.MaxY; }
public bool IsOverlappedWith(OverlappingRectangle other) { return IsAnyOfTheCornerPointsWithIn(other) || other.IsAnyOfTheCornerPointsWithIn(this); }