internal Vec2i ClosestPointTo(Vec2i v)
        {
            Intervali x = new Intervali(min.X, max.X);
            Intervali y = new Intervali(min.Y, max.Y);

            return(new Vec2i(x.GetClosestValueTo(v.X), y.GetClosestValueTo(v.Y)));
        }
Exemple #2
0
 public Intervali Merge(Intervali interval)
 {
     if (interval.max >= this.min && this.max >= interval.min)
     {
         return(new Intervali(Math.Max(this.min, interval.min), Math.Min(this.max, interval.max)));
     }
     return(null);
 }
        public bool Overlaps(Box2i box)
        {
            Intervali x1 = new Intervali(min.X, max.X);
            Intervali x2 = new Intervali(box.min.X, box.max.X);

            if (x1.Overlaps(x2))
            {
                Intervali y1 = new Intervali(min.Y, max.Y);
                Intervali y2 = new Intervali(box.min.Y, box.max.Y);
                return(y1.Overlaps(y2));
            }
            return(false);
        }
Exemple #4
0
        internal Tuple <IntervaliList, IntervaliList> Cut(Intervali i)
        {
            IntervaliList free       = new IntervaliList();
            IntervaliList overlapped = new IntervaliList();

            if (min < i.min)
            {
                free.Add(new Intervali(min, i.min));
            }
            if (max > i.max)
            {
                free.Add(new Intervali(i.max, max));
            }
            overlapped.Add(Merge(i));
            return(new Tuple <IntervaliList, IntervaliList>(free, overlapped));
        }
Exemple #5
0
        public static Boxi CreateFromPointList(Vec2i[] points, Intervali heightInterval)
        {
            Boxi b = MaxMinBox();

            foreach (Vec2i point in points)
            {
                b.AddPointToBoundingBox(point);
            }
            if (heightInterval.Min < b.min[1])
            {
                b.min[1] = heightInterval.Min;
            }
            if (heightInterval.Max > b.max[1])
            {
                b.max[1] = heightInterval.Max;
            }

            return(b);
        }
Exemple #6
0
        internal List <Intervali> Remove(Intervali interval)
        {
            List <Intervali> ret = new List <Intervali>();

            if (interval.max < min || interval.min > max)
            {
                return(ret);
            }
            Intervali newInt = new Intervali(min, interval.min);

            if (newInt.Length > 0)
            {
                ret.Add(newInt);
            }
            newInt = new Intervali(interval.max, max);
            if (newInt.Length > 0)
            {
                ret.Add(newInt);
            }
            return(ret);
        }
Exemple #7
0
 internal static Boxi CreateFromPointList(System.Collections.ObjectModel.ReadOnlyCollection <Vec2i> points, Intervali interval)
 {
     Vec2i[] array = new Vec2i[points.Count];
     for (int i = 0; i < points.Count; ++i)
     {
         array[i] = points[i];
     }
     return(CreateFromPointList(array, interval));
 }
Exemple #8
0
 public void Add(Intervali interval)
 {
     this.min = Math.Min(min, interval.min);
     this.max = Math.Max(max, interval.max);
     length   = this.max - this.min;
 }
Exemple #9
0
 internal bool Overlaps(Intervali interval)
 {
     return(max > interval.min && min < interval.max);
 }
Exemple #10
0
 public Intervali(Intervali interval)
 {
     this.min    = interval.min;
     this.max    = interval.max;
     this.length = interval.length;
 }