示例#1
0
        public DoubleRectangle Union(DoubleRectangle o)
        {
            var x1 = Math.Min(X, o.X);
            var x2 = Math.Max(X + Width, o.X + o.Width);
            var y1 = Math.Min(Y, o.Y);
            var y2 = Math.Max(Y + Height, o.Y + o.Height);

            return(new DoubleRectangle(x1, y1, x2 - x1, y2 - y1));
        }
示例#2
0
        public DoubleRectangle Intersection(DoubleRectangle o)
        {
            if (!Intersects(o))
            {
                return(new DoubleRectangle(double.NaN, double.NaN, double.NaN, double.NaN));
            }

            var x1 = Math.Max(X, o.X);
            var x2 = Math.Min(X + Width, o.X + o.Width);
            var y1 = Math.Max(Y, o.Y);
            var y2 = Math.Min(Y + Height, o.Y + o.Height);

            return(new DoubleRectangle(x1, y1, x2 - x1, y2 - y1));
        }
 public bool Intersects(DoubleRectangle o) => !(X > o.X + o.Width || o.X > X + Width || Y > o.Y + o.Height || o.Y > Y + Height);
示例#4
0
 public bool ContainsCompletely(DoubleRectangle o)
 => X <= o.X && Y <= o.Y && X + Width >= o.X + o.Width && Y + Height >= o.Y + o.Height;
示例#5
0
 public static DoubleRectangle Union(DoubleRectangle r1, DoubleRectangle r2) => r1.Union(r2);
示例#6
0
 public static DoubleRectangle Intersection(DoubleRectangle r1, DoubleRectangle r2) => r1.Intersection(r2);
示例#7
0
 public bool StrictlyIntersects(DoubleRectangle o) =>
 !(X >= o.X + o.Width || o.X >= X + Width || Y >= o.Y + o.Height || o.Y >= Y + Height);