Exemplo n.º 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;
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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));
 }
Exemplo n.º 4
0
 public bool ContainsInclusive(Rect2D r)
 {
     return((Left <= r.Left) && (Right >= r.Right) && (Top <= r.Top) && (Bottom >= r.Bottom));
 }
Exemplo n.º 5
0
 public bool Contains(Rect2D r)
 {
     return((Left < r.Left) && (Right > r.Right) && (Top < r.Top) && (Bottom > r.Bottom));
 }
Exemplo n.º 6
0
 public bool Equals(Rect2D r)
 {
     return(Equals(r, MathUtil.EPSILON));
 }