/* assuming Rectangle with members x,y,width,height, also assuming that x and y denote the center of the rectangle */
bool intersect(const Rectangle& rectangle1, const Rectangle& rectangle2)
{
if(abs(rectangle1.x-rectangle2.x)<(rectangle1.width/2+rectangle2.width/2)
{
if(abs(rectangle1.y-rectangle2.y)<(rectangle1.height/2+rectangle2.height/2)
{
returntrue;
}
}
returnfalse;
}
If the rectangles are NOT axis aligned, you'd have to go for a more general solution like SAT.