/*
************************************************************************
Return a Rect object that is the intersection of 'this' with 'rect'
************************************************************************ */
Rect Rect::getIntersection( const Rect & rect) const
{
// check for total exclusion
if ((d_right > rect.d_left) &&
(d_left < rect.d_right) &&
(d_bottom > rect.d_top) &&
(d_top < rect.d_bottom))
{
Rect temp;
// fill in temp with the intersection
temp.d_left = (d_left > rect.d_left) ? d_left : rect.d_left;
temp.d_right = (d_right < rect.d_right) ? d_right : rect.d_right;
temp.d_top = (d_top > rect.d_top) ? d_top : rect.d_top;
temp.d_bottom = (d_bottom < rect.d_bottom) ? d_bottom : rect.d_bottom;
return temp;
}
else
{
return Rect( 0.0f , 0.0f , 0.0f , 0.0f );
}
}
Return a Rect object that is the intersection of 'this' with 'rect'
************************************************************************ */
Rect Rect::getIntersection( const Rect & rect) const
{
// check for total exclusion
if ((d_right > rect.d_left) &&
(d_left < rect.d_right) &&
(d_bottom > rect.d_top) &&
(d_top < rect.d_bottom))
{
Rect temp;
// fill in temp with the intersection
temp.d_left = (d_left > rect.d_left) ? d_left : rect.d_left;
temp.d_right = (d_right < rect.d_right) ? d_right : rect.d_right;
temp.d_top = (d_top > rect.d_top) ? d_top : rect.d_top;
temp.d_bottom = (d_bottom < rect.d_bottom) ? d_bottom : rect.d_bottom;
return temp;
}
else
{
return Rect( 0.0f , 0.0f , 0.0f , 0.0f );
}
}