Exemple #1
0
 public LDRect(LDRect rect)
 {
     this.xp = rect.xp;
     this.yp = rect.yp;
     this.w = rect.w;
     this.h = rect.h;
 }
Exemple #2
0
 public LDRect(LDRect rect)
 {
     this.xp = rect.xp;
     this.yp = rect.yp;
     this.w  = rect.w;
     this.h  = rect.h;
 }
Exemple #3
0
 public LDPolygon(LDRect r)
 {
     this.Add(r.topLeft());
     this.Add(r.topRight());
     this.Add(r.bottomRight());
     this.Add(r.bottomLeft());
 }
Exemple #4
0
        //矩形に含まれるかどうかの軽量な簡易当たり判定
        public bool isPreHit(LDPoint pt, float hitRange = 0)
        {
            LDRect rect = getBounds();

            //上下左右を拡張
            rect.adjust(-hitRange, -hitRange, hitRange, hitRange);

            return(rect.contains(pt));
        }
Exemple #5
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);
        }
Exemple #6
0
        public void copyFrom(LDGridTransform src)
        {
            m_gridPoints = new List <List <LDPoint> >();
            foreach (var p in src.m_gridPoints)
            {
                m_gridPoints.Add(new List <LDPoint>());
                foreach (var q in p)
                {
                    m_gridPoints[m_gridPoints.Count - 1].Add(new LDPoint(q));
                }
            }

            m_originRect = new LDRect(src.m_originRect);
        }
Exemple #7
0
        public LDGridTransform createExtendedGrid(int extend = 1)
        {
            LDRect          bounds = getBounds();
            LDGridTransform grid   = new LDGridTransform(
                getPoint(0, 0).x() - bounds.width(),
                getPoint(0, 0).y() - bounds.height(),
                bounds.width() + bounds.width() * 2,
                bounds.height() + bounds.height() * 2,
                getRow() + 1, getColumn() + 1
                );

            grid.copyFrom(this, 1, 1);
            return(grid);
        }
Exemple #8
0
        public LDRect normalized()
        {
            LDRect normalized = new LDRect(this);

            if (normalized.w < 0)
            {
                normalized.xp = this.right();
                normalized.w *= -1;
            }
            if (normalized.h < 0)
            {
                normalized.yp = this.bottom();
                normalized.h *= -1;
            }
            return(normalized);
        }
Exemple #9
0
        //時計回りに4点
        public LDGridTransform(LDPoint topLeft, LDPoint topRight, LDPoint bottomRight, LDPoint bottomLeft, int row = 1, int col = 1)
        {
            m_originRect = math.PointUtil.getBoundingRect(new LDPointList { topLeft, topRight, bottomLeft, bottomRight });

            LDQuadTransform quad = new LDQuadTransform(topLeft, topRight, bottomRight, bottomLeft);

            for (int i = 0; i < row + 1; ++i)
            {
                m_gridPoints.Add(new List<LDPoint>());
                for (int j = 0; j < col + 1; ++j)
                {
                    m_gridPoints[i].Add(quad.transform((float)j / col, (float)i / row));
                }
            }

            clearBoundsCache();
        }
Exemple #10
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);
        }
Exemple #11
0
 public bool intersects(LDRect r)
 {
     throw new NotImplementedException();
 }
Exemple #12
0
 public bool intersects(LDRect r)
 {
     return this.intersected(r).isValid();
 }
Exemple #13
0
 public bool contains(LDRect r)
 {
     throw new NotImplementedException();
 }
Exemple #14
0
 public LDRect intersected(LDRect other)
 {
     throw new NotImplementedException();
 }
Exemple #15
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;
        }
Exemple #16
0
 public LDRect normalized()
 {
     LDRect normalized = new LDRect(this);
     if (normalized.w < 0)
     {
         normalized.xp = this.right();
         normalized.w *= -1;
     }
     if (normalized.h < 0)
     {
         normalized.yp = this.bottom();
         normalized.h *= -1;
     }
     return normalized;
 }
Exemple #17
0
 public LDRect united(LDRect other)
 {
     throw new NotImplementedException();
 }
Exemple #18
0
 public void copyFrom(LDGridTransform src)
 {
     m_gridPoints = src.m_gridPoints;
     m_originRect = src.m_originRect;
 }
Exemple #19
0
 public bool contains(LDRect r)
 {
     throw new NotImplementedException();
 }
Exemple #20
0
 public bool intersects(LDRect r)
 {
     throw new NotImplementedException();
 }
Exemple #21
0
        public void copyFrom(LDGridTransform src)
        {
            m_gridPoints = new List<List<LDPoint>>();
            foreach(var p in src.m_gridPoints)
            {
                m_gridPoints.Add(new List<LDPoint>());
                foreach(var q in p)
                {
                    m_gridPoints[m_gridPoints.Count - 1].Add(new LDPoint(q));
                }
            }

            m_originRect = new LDRect(src.m_originRect);
        }
Exemple #22
0
 public bool contains(LDRect r)
 {
     return this.contains(r.topLeft()) && this.contains(r.topRight()) && this.contains(r.bottomLeft()) && this.contains(r.bottomRight());
 }
Exemple #23
0
        public LDRect getBounds()
        {
            if (m_cacheBounds.size() == new LDSize(0, 0))
            {
                //TODO const関数内でのmutableの変更はスレッドセーフにしないといけない?
                m_cacheBounds = math.PointUtil.getBoundingRect(toForm());
            }

            return m_cacheBounds;
        }
Exemple #24
0
 public bool contains(LDRect r)
 {
     return(this.contains(r.topLeft()) && this.contains(r.topRight()) && this.contains(r.bottomLeft()) && this.contains(r.bottomRight()));
 }
Exemple #25
0
 public bool intersects(LDRect r)
 {
     return(this.intersected(r).isValid());
 }