Beispiel #1
0
 /// Union
 ///
 /// Sets the rectangle to the union of two rectangles r1 and r2.
 /// If either rect is empty, it is ignored. If both are empty, the rectangle
 /// is set to r1.
 /// Either of the input rectangle references may refer to the destination rectangle.
 ///
 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;
     }
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public bool ContainsInclusive(Rect2D r, double epsilon)
 {
     return(((Left - epsilon) <= r.Left) && ((Right + epsilon) >= r.Right) && ((Top - epsilon) <= r.Top) && ((Bottom + epsilon) >= r.Bottom));
 }
Beispiel #4
0
 public bool ContainsInclusive(Rect2D r)
 {
     return((Left <= r.Left) && (Right >= r.Right) && (Top <= r.Top) && (Bottom >= r.Bottom));
 }
Beispiel #5
0
 public bool Contains(Rect2D r)
 {
     return((Left < r.Left) && (Right > r.Right) && (Top < r.Top) && (Bottom > r.Bottom));
 }
Beispiel #6
0
 public bool Equals(Rect2D r)
 {
     return(Equals(r, MathUtil.EPSILON));
 }