public Rectangle Intersect(Rectangle rectangle)
{
if (!Intersects(rectangle))
{
return Empty;
}
float[] horizontal = {Left, Right, rectangle.Left, rectangle.Right};
float[] vertical = {Bottom, Top, rectangle.Bottom, rectangle.Top};
Array.Sort(horizontal);
Array.Sort(vertical);
float left = horizontal[1];
float bottom = vertical[1];
float right = horizontal[2];
float top = vertical[2];
return new Rectangle(left, top, right - left, bottom - top);
}