Пример #1
0
        public LDRect intersected(LDRect other)
        {
            LDRect a = this.normalized();
            LDRect b = other.normalized();

            LDRect intersected = new LDRect(0, 0, 0, 0);

            intersected.setTop(Math.Max(a.top(), b.top()));
            intersected.setBottom(Math.Min(a.bottom(), b.bottom()));
            intersected.setLeft(Math.Max(a.left(), b.left()));
            intersected.setRight(Math.Min(a.right(), b.right()));
            return(intersected);
        }
Пример #2
0
        public LDRect boundingRect()
        {
            if (this.Count == 0)
            {
                return(new LDRect(0, 0, 0, 0));
            }

            LDRect boundingRect = new LDRect(this[0], this[0]);

            foreach (var p in this)
            {
                boundingRect.setBottom(Math.Max(p.y(), boundingRect.bottom()));
                boundingRect.setRight(Math.Max(p.x(), boundingRect.right()));
                boundingRect.setLeft(Math.Min(p.x(), boundingRect.left()));
                boundingRect.setTop(Math.Min(p.y(), boundingRect.top()));
            }
            return(boundingRect);
        }
Пример #3
0
        public LDRect united(LDRect other)
        {
            LDRect a = this.normalized();
            LDRect b = other.normalized();

            LDRect intersected = new LDRect(0, 0, 0, 0);
            intersected.setTop(Math.Min(a.top(), b.top()));
            intersected.setBottom(Math.Max(a.bottom(), b.bottom()));
            intersected.setLeft(Math.Min(a.left(), b.left()));
            intersected.setRight(Math.Max(a.right(), b.right()));
            return intersected;
        }