コード例 #1
0
        public double Distance(IReadOnlyPointInt32 stop)
        {
            int dx = stop.X - X;
            int dy = stop.Y - Y;

            return(Math.Sqrt(dx * dx + dy * dy));
        }
コード例 #2
0
ファイル: PointInt32.cs プロジェクト: svejdo1/astar
 public static IEnumerable<PointInt32> GetOrthogonalAdjectedCoordinates(IReadOnlyPointInt32 coordinates, int step)
 {
     yield return new PointInt32(coordinates.X - step, coordinates.Y);
       yield return new PointInt32(coordinates.X, coordinates.Y - step);
       yield return new PointInt32(coordinates.X + step, coordinates.Y);
       yield return new PointInt32(coordinates.X, coordinates.Y + step);
 }
コード例 #3
0
        public bool IsNeighbor(IReadOnlyPointInt32 anotherPoint)
        {
            int dx = Math.Abs(X - anotherPoint.X);
            int dy = Math.Abs(Y - anotherPoint.Y);

            return(dx <= 1 && dy <= 1);
        }
コード例 #4
0
        public static IEnumerable <PointInt32> GetOrthogonalAdjectedCoordinates(IReadOnlyPointInt32 coordinates, int step)
        {
            yield return(new PointInt32(coordinates.X - step, coordinates.Y));

            yield return(new PointInt32(coordinates.X, coordinates.Y - step));

            yield return(new PointInt32(coordinates.X + step, coordinates.Y));

            yield return(new PointInt32(coordinates.X, coordinates.Y + step));
        }
コード例 #5
0
ファイル: PointInt32.cs プロジェクト: svejdo1/astar
 public static IEnumerable<PointInt32> GetAdjectedCoordinates(IReadOnlyPointInt32 coordinates)
 {
     yield return new PointInt32(coordinates.X - 1, coordinates.Y);
       yield return new PointInt32(coordinates.X + 1, coordinates.Y);
       yield return new PointInt32(coordinates.X - 1, coordinates.Y - 1);
       yield return new PointInt32(coordinates.X, coordinates.Y - 1);
       yield return new PointInt32(coordinates.X + 1, coordinates.Y - 1);
       yield return new PointInt32(coordinates.X - 1, coordinates.Y + 1);
       yield return new PointInt32(coordinates.X, coordinates.Y + 1);
       yield return new PointInt32(coordinates.X + 1, coordinates.Y + 1);
 }
コード例 #6
0
        public static IEnumerable <PointInt32> GetAdjectedCoordinates(IReadOnlyPointInt32 coordinates)
        {
            yield return(new PointInt32(coordinates.X - 1, coordinates.Y));

            yield return(new PointInt32(coordinates.X + 1, coordinates.Y));

            yield return(new PointInt32(coordinates.X - 1, coordinates.Y - 1));

            yield return(new PointInt32(coordinates.X, coordinates.Y - 1));

            yield return(new PointInt32(coordinates.X + 1, coordinates.Y - 1));

            yield return(new PointInt32(coordinates.X - 1, coordinates.Y + 1));

            yield return(new PointInt32(coordinates.X, coordinates.Y + 1));

            yield return(new PointInt32(coordinates.X + 1, coordinates.Y + 1));
        }
コード例 #7
0
 public bool IsOrthogonalNeighborOrEqual(IReadOnlyPointInt32 anotherPoint)
 {
     return((X == anotherPoint.X && Y == anotherPoint.Y) ||
            IsOrthogonalNeighbor(anotherPoint));
 }
コード例 #8
0
 public bool IsOrthogonalNeighbor(IReadOnlyPointInt32 anotherPoint)
 {
     return((X == anotherPoint.X && (Y == anotherPoint.Y - 1 || Y == anotherPoint.Y + 1)) ||
            (Y == anotherPoint.Y && (X == anotherPoint.X - 1 || X == anotherPoint.X + 1)));
 }
コード例 #9
0
 public PointInt32(IReadOnlyPointInt32 point)
 {
     m_X = point.X;
     m_Y = point.Y;
 }
コード例 #10
0
 public static IEnumerable <PointInt32> GetOrthogonalAdjectedCoordinates(IReadOnlyPointInt32 coordinates)
 {
     return(GetOrthogonalAdjectedCoordinates(coordinates, 1));
 }
コード例 #11
0
ファイル: PointInt32.cs プロジェクト: svejdo1/astar
 public double Distance(IReadOnlyPointInt32 stop)
 {
     int dx = stop.X - X;
       int dy = stop.Y - Y;
       return Math.Sqrt(dx * dx + dy * dy);
 }
コード例 #12
0
ファイル: PointInt32.cs プロジェクト: svejdo1/astar
 public static IEnumerable<PointInt32> GetOrthogonalAdjectedCoordinates(IReadOnlyPointInt32 coordinates)
 {
     return GetOrthogonalAdjectedCoordinates(coordinates, 1);
 }
コード例 #13
0
ファイル: PointInt32.cs プロジェクト: svejdo1/astar
 public PointInt32(IReadOnlyPointInt32 point)
 {
     m_X = point.X;
       m_Y = point.Y;
 }
コード例 #14
0
ファイル: PointInt32.cs プロジェクト: svejdo1/astar
 public bool IsOrthogonalNeighborOrEqual(IReadOnlyPointInt32 anotherPoint)
 {
     return (X == anotherPoint.X && Y == anotherPoint.Y) ||
     IsOrthogonalNeighbor(anotherPoint);
 }
コード例 #15
0
ファイル: PointInt32.cs プロジェクト: svejdo1/astar
 public bool IsOrthogonalNeighbor(IReadOnlyPointInt32 anotherPoint)
 {
     return (X == anotherPoint.X && (Y == anotherPoint.Y - 1 || Y == anotherPoint.Y + 1)) ||
     (Y == anotherPoint.Y && (X == anotherPoint.X - 1 || X == anotherPoint.X + 1));
 }
コード例 #16
0
ファイル: PointInt32.cs プロジェクト: svejdo1/astar
 public bool IsNeighbor(IReadOnlyPointInt32 anotherPoint)
 {
     int dx = Math.Abs(X - anotherPoint.X);
       int dy = Math.Abs(Y - anotherPoint.Y);
       return dx <= 1 && dy <= 1;
 }