// Point in rect
bool inRange(int val, int min, int max) {
return val >= std::min(min, max) && val <= std::max(min, max);
}
bool pointInRect(int x, int y, Rect &rect) {
return inRange(x, rect.x, rect.x + rect.w) &&
inRange(y, rect.y, rect.y + rect.h);
}
// Rect to rect
// Method: Range of intersections
// Constraint: no rotation
bool rangeIntersect(int min0, int max0, int min1, int max1) {
return std::max(min0, max0) >= std::min(min1, max1) &&
std::min(min0, max0) <= std::max(min1, max1);
}
bool rectIntersect(Rect &a, Rect &b) {
return rangeIntersect(a.x, a.x + a.w, b.x, b.x + b.w) &&
rangeIntersect(a.y, a.y + a.h, b.y, b.y + b.h);
}
bool circRectIntersect(Circ &a, Rect &b) {
}