public bool Intersection(Rect2D r1, Rect2D r2)
        {
            if (!TriangulationUtil.RectsIntersect(r1, r2))
            {
                Left = Right = Top = Bottom = 0.0;
                return(false);
            }

            Left   = (r1.Left > r2.Left)   ? r1.Left   : r2.Left;
            Top    = (r1.Top < r2.Top)   ? r1.Top    : r2.Top;
            Right  = (r1.Right < r2.Right)  ? r1.Right  : r2.Right;
            Bottom = (r1.Bottom > r2.Bottom) ? r1.Bottom : r2.Bottom;

            return(true);
        }
 public void Union(Rect2D r1, Rect2D r2)
 {
     if ((r2.Right == r2.Left) || (r2.Bottom == r2.Top))
     {
         Set(r1);
     }
     else if ((r1.Right == r1.Left) || (r1.Bottom == r1.Top))
     {
         Set(r2);
     }
     else
     {
         Left   = (r1.Left < r2.Left) ? r1.Left : r2.Left;
         Top    = (r1.Top > r2.Top) ? r1.Top : r2.Top;
         Right  = (r1.Right > r2.Right) ? r1.Right : r2.Right;
         Bottom = (r1.Bottom < r2.Bottom) ? r1.Bottom : r2.Bottom;
     }
 }
 public bool Equals(Rect2D r, double epsilon)
 {
     if (!MathUtil.AreValuesEqual(MinX, r.MinX, epsilon))
     {
         return(false);
     }
     if (!MathUtil.AreValuesEqual(MaxX, r.MaxX))
     {
         return(false);
     }
     if (!MathUtil.AreValuesEqual(MinY, r.MinY, epsilon))
     {
         return(false);
     }
     if (!MathUtil.AreValuesEqual(MaxY, r.MaxY, epsilon))
     {
         return(false);
     }
     return(true);
 }
 public static bool RectsIntersect(Rect2D r1, Rect2D r2)
 {
     return((r1.Right > r2.Left) && (r1.Left < r2.Right) && (r1.Bottom > r2.Top) && (r1.Top < r2.Bottom));
 }
 public bool Intersects(Rect2D r)
 {
     return((Right > r.Left) && (Left < r.Right) && (Bottom < r.Top) && (Top > r.Bottom));
 }
 public bool ContainsInclusive(Rect2D r, double epsilon)
 {
     return(((Left - epsilon) <= r.Left) && ((Right + epsilon) >= r.Right) && ((Top - epsilon) <= r.Top) && ((Bottom + epsilon) >= r.Bottom));
 }
 public bool ContainsInclusive(Rect2D r)
 {
     return((Left <= r.Left) && (Right >= r.Right) && (Top <= r.Top) && (Bottom >= r.Bottom));
 }
 public bool Contains(Rect2D r)
 {
     return((Left < r.Left) && (Right > r.Right) && (Top < r.Top) && (Bottom > r.Bottom));
 }
 public bool Equals(Rect2D r)
 {
     return(Equals(r, MathUtil.EPSILON));
 }