Esempio n. 1
0
        public Range(Position startPosition, int width, int height)
        {
            upperLeft = startPosition;
            lowerRight = new Position(startPosition.X + width, startPosition.Y + height);

            toString = String.Empty;
            UpdateToString();
        }
Esempio n. 2
0
        public Range(Position upperLeft, Position lowerRight)
        {
            this.upperLeft = upperLeft;
            this.lowerRight = lowerRight;

            toString = String.Empty;
            UpdateToString();
        }
Esempio n. 3
0
 public static double Distance(Position a, Position b)
 {
     return Math.Sqrt(Math.Pow(a.x - b.x, 2) + Math.Pow(a.y - b.y, 2));
 }
Esempio n. 4
0
 public bool Contains(Position position)
 {
     return position.X >= upperLeft.X && position.Y < lowerRight.Y &&
            position.X < lowerRight.X && position.Y >= upperLeft.Y;
 }
Esempio n. 5
0
        public static Position Clamp(Position value, Position min, Position max)
        {
            Position newValue = value;
            if (newValue.x > max.x) newValue.x = max.x;
            else if (newValue.x < min.x) newValue.x = min.x;

            if (newValue.y > max.y) newValue.y = max.y;
            else if (newValue.y < min.y) newValue.y = min.y;

            return newValue;
        }