Exemplo n.º 1
0
 public static GeoRect Intersect(GeoRect rect1, GeoRect rect2)
 {
     if (IntersectionExist(rect1, rect2))
     {
         double x      = Math.Max(rect1.Left, rect2.Left);
         double y      = Math.Max(rect1.Bottom, rect2.Bottom);
         double width  = Math.Max((double)(Math.Min(rect1.Right, rect2.Right) - x), (double)0.0);
         double height = Math.Max((double)(Math.Min(rect1.Top, rect2.Top) - y), (double)0.0);
         return(new GeoRect(x, y, width, height));
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 public static GeoRect Intersect(GeoRect rect1, GeoRect rect2)
 {
     if (IntersectionExist(rect1, rect2))
     {
         double x = Math.Max(rect1.Left, rect2.Left);
         double y = Math.Max(rect1.Bottom, rect2.Bottom);
         double width = Math.Max((double)(Math.Min(rect1.Right, rect2.Right) - x), (double)0.0);
         double height = Math.Max((double)(Math.Min(rect1.Top, rect2.Top) - y), (double)0.0);
         return new GeoRect(x, y, width, height);
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 3
0
 public static bool IntersectionExist(GeoRect rect1, GeoRect rect2)
 {
     return(rect1.Left <= rect2.Right && rect1.Top >= rect2.Bottom && rect1.Bottom <= rect2.Top && rect1.Right >= rect2.Left);
 }
Exemplo n.º 4
0
 public static bool IntersectionExist(GeoRect rect1, GeoRect rect2)
 {
     return (rect1.Left <= rect2.Right && rect1.Top >= rect2.Bottom && rect1.Bottom <= rect2.Top && rect1.Right >= rect2.Left);
 }