コード例 #1
0
ファイル: Range.cs プロジェクト: AleksandarDev/LD26
        public Range(Position startPosition, int width, int height)
        {
            upperLeft = startPosition;
            lowerRight = new Position(startPosition.X + width, startPosition.Y + height);

            toString = String.Empty;
            UpdateToString();
        }
コード例 #2
0
ファイル: Range.cs プロジェクト: AleksandarDev/LD26
        public Range(Position upperLeft, Position lowerRight)
        {
            this.upperLeft = upperLeft;
            this.lowerRight = lowerRight;

            toString = String.Empty;
            UpdateToString();
        }
コード例 #3
0
ファイル: Position.cs プロジェクト: AleksandarDev/LD26
 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));
 }
コード例 #4
0
ファイル: Range.cs プロジェクト: AleksandarDev/LD26
 public bool Contains(Position position)
 {
     return position.X >= upperLeft.X && position.Y < lowerRight.Y &&
            position.X < lowerRight.X && position.Y >= upperLeft.Y;
 }
コード例 #5
0
ファイル: Position.cs プロジェクト: AleksandarDev/LD26
        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;
        }