示例#1
0
 public GridBoundingBox(GridInterval xInterval, GridInterval yInterval)
 {
     XInterval   = xInterval;
     YInterval   = yInterval;
     TopLeft     = new GridCoordinatePair(XInterval.Min, YInterval.Min);
     TopRight    = new GridCoordinatePair(XInterval.Max, YInterval.Min);
     BottomRight = new GridCoordinatePair(XInterval.Max, YInterval.Max);
     BottomLeft  = new GridCoordinatePair(XInterval.Min, YInterval.Max);
 }
示例#2
0
        public static GridBoundingBox FromSize(int minX, int minY, int width, int height)
        {
            if (width < 1 || height < 1)
            {
                throw new ArgumentException("Size must be greater than 0");
            }
            var xInterval = GridInterval.FromExclusiveMax(minX, minX + width);
            var yInterval = GridInterval.FromExclusiveMax(minY, minY + height);

            return(new GridBoundingBox(xInterval, yInterval));
        }
示例#3
0
        public static GridBoundingBox FromMinMax(int minX, int minY, int maxX, int maxY)
        {
            if (minX > maxX || minY > maxY)
            {
                throw new ArgumentException("min cannot be greater than max");
            }
            var xInterval = new GridInterval(minX, maxX);
            var yInterval = new GridInterval(minY, maxY);

            return(new GridBoundingBox(xInterval, yInterval));
        }
示例#4
0
        public static GridBoundingBox FromMinMaxExcl(int minX, int minY, int maxXExcl, int maxYExcl)
        {
            if (maxXExcl <= minX || maxYExcl <= minY)
            {
                throw new ArgumentException("Max is exclusive and must be greater than Min");
            }

            var xInterval = GridInterval.FromExclusiveMax(minX, maxXExcl);
            var yInterval = GridInterval.FromExclusiveMax(minY, maxYExcl);

            return(new GridBoundingBox(xInterval, yInterval));
        }
示例#5
0
        public static GridInterval[] Separate(GridInterval i1, GridInterval i2)
        {
            var depth = i1.Depth(i2);

            if (depth == 0)
            {
                return new[] { i1, i2 }
            }
            ;
            var t1 = GridConvert.ToGrid(depth / 2.0);
            var t2 = depth % 2 == 0 ? -t1 : GridConvert.ToGrid(-(depth + 1) / 2.0);

            return(new[] { i1.Translation(t1), i2.Translation(t2) });
        }