コード例 #1
0
ファイル: LDRect.cs プロジェクト: johndpope/math
        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
ファイル: LDPolygon.cs プロジェクト: johndpope/math
        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);
        }