Below is comparing the sides of the inner rectangle to the sides of the outer rectangle
if Right2 < Right1 && Left2 > Left1 && Top2 > Top1 && Bottom2 < Bottom1
Implementation:
struct RECT
{
double x,y, w,h;
RECT(double a,double b,double c,double d)
{
x=a; y=b; w=c; h=d;
}
};
bool contains(RECT R1, RECT R2)
{
if ( (R2.x+R2.w) < (R1.x+R1.w)
&& (R2.x) > (R1.x)
&& (R2.y) > (R1.y)
&& (R2.y+R2.h) < (R1.y+R1.h)
)
{
return true;
}
else
{
return false;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…