示例#1
0
 public bool Contains(Vector2X point)
 {
     if (point.x >= this.x && point.x < this.xMax && point.y >= (double)this.y)
     {
         return(point.y < this.yMax);
     }
     return(false);
 }
示例#2
0
 public Vector2X transformVector(Vector2X vec, Vector2X result = null)
 {
     if (result == null)
     {
         result = new Vector2X();
     }
     result.x = a * vec.x + c * vec.y + tx;
     result.y = b * vec.x + d * vec.y + ty;
     return(result);
 }
示例#3
0
        public RectangleX getBoundRect(RectangleX rect)
        {
            RectangleX result = new RectangleX();

            if (rect.width < 0 || rect.height < 0)
            {
                return(result);
            }
            Vector2X p1 = transformVector(new Vector2X(rect.x, rect.y));
            Vector2X p2 = transformVector(new Vector2X(rect.x + rect.width, rect.y));
            Vector2X p3 = transformVector(new Vector2X(rect.x + rect.width, rect.y + rect.height));
            Vector2X p4 = transformVector(new Vector2X(rect.x, rect.y + rect.height));

            Vector2X minPos2 = new Vector2X();
            Vector2X maxPos2 = new Vector2X();

            minPos2.x = p1.x;
            if (minPos2.x > p2.x)
            {
                minPos2.x = p2.x;
            }
            if (minPos2.x > p3.x)
            {
                minPos2.x = p3.x;
            }
            if (minPos2.x > p4.x)
            {
                minPos2.x = p4.x;
            }
            minPos2.y = p1.y;
            if (minPos2.y > p2.y)
            {
                minPos2.y = p2.y;
            }
            if (minPos2.y > p3.y)
            {
                minPos2.y = p3.y;
            }
            if (minPos2.y > p4.y)
            {
                minPos2.y = p4.y;
            }

            maxPos2.x = p1.x;
            if (maxPos2.x < p2.x)
            {
                maxPos2.x = p2.x;
            }
            if (maxPos2.x < p3.x)
            {
                maxPos2.x = p3.x;
            }
            if (maxPos2.x < p4.x)
            {
                maxPos2.x = p4.x;
            }
            maxPos2.y = p1.y;
            if (maxPos2.y < p2.y)
            {
                maxPos2.y = p2.y;
            }
            if (maxPos2.y < p3.y)
            {
                maxPos2.y = p3.y;
            }
            if (maxPos2.y < p4.y)
            {
                maxPos2.y = p4.y;
            }

            result.x      = minPos2.x;
            result.y      = minPos2.y;
            result.width  = (maxPos2.x - minPos2.x);
            result.height = (maxPos2.y - minPos2.y);
            return(result);
        }
示例#4
0
        public Rect getBoundRect(Vector2 minPos, Vector2 maxPos)
        {
            Rect result = new Rect();

            if (maxPos.x - minPos.x < 0 || maxPos.y - minPos.y < 0)
            {
                return(result);
            }
            Vector2X p1 = transformVector(new Vector2X(minPos.x, minPos.y));
            Vector2X p2 = transformVector(new Vector2X(maxPos.x, minPos.y));
            Vector2X p3 = transformVector(new Vector2X(maxPos.x, maxPos.y));
            Vector2X p4 = transformVector(new Vector2X(minPos.x, maxPos.y));

            Vector2X minPos2 = new Vector2X();
            Vector2X maxPos2 = new Vector2X();

            minPos2.x = p1.x;
            if (minPos2.x > p2.x)
            {
                minPos2.x = p2.x;
            }
            if (minPos2.x > p3.x)
            {
                minPos2.x = p3.x;
            }
            if (minPos2.x > p4.x)
            {
                minPos2.x = p4.x;
            }
            minPos2.y = p1.y;
            if (minPos2.y > p2.y)
            {
                minPos2.y = p2.y;
            }
            if (minPos2.y > p3.y)
            {
                minPos2.y = p3.y;
            }
            if (minPos2.y > p4.y)
            {
                minPos2.y = p4.y;
            }

            maxPos2.x = p1.x;
            if (maxPos2.x < p2.x)
            {
                maxPos2.x = p2.x;
            }
            if (maxPos2.x < p3.x)
            {
                maxPos2.x = p3.x;
            }
            if (maxPos2.x < p4.x)
            {
                maxPos2.x = p4.x;
            }
            maxPos2.y = p1.y;
            if (maxPos2.y < p2.y)
            {
                maxPos2.y = p2.y;
            }
            if (maxPos2.y < p3.y)
            {
                maxPos2.y = p3.y;
            }
            if (maxPos2.y < p4.y)
            {
                maxPos2.y = p4.y;
            }

            result.x      = minPos2.x;
            result.y      = minPos2.y;
            result.width  = (maxPos2.x - minPos2.x);
            result.height = (maxPos2.y - minPos2.y);
            return(result);
        }