private int NumCornersIntersect(Rectangle r)
{
//We play some logic games to avoid calling contains() which can be expensive.
// for partial, we exit early with 1 and ignore bool.
bool b = (Contains(r.GetMinX(), r.GetMinY()));
if (Contains(r.GetMinX(), r.GetMaxY()))
{
if (!b)
return 1;//partial
}
else
{
if (b)
return 1;//partial
}
if (Contains(r.GetMaxX(), r.GetMinY()))
{
if (!b)
return 1;//partial
}
else
{
if (b)
return 1;//partial
}
if (Contains(r.GetMaxX(), r.GetMaxY()))
{
if (!b)
return 1;//partial
}
else
{
if (b)
return 1;//partial
}
return b ? 4 : 0;
}