public double Distance(IReadOnlyPointInt32 stop) { int dx = stop.X - X; int dy = stop.Y - Y; return(Math.Sqrt(dx * dx + dy * dy)); }
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); }
public bool IsNeighbor(IReadOnlyPointInt32 anotherPoint) { int dx = Math.Abs(X - anotherPoint.X); int dy = Math.Abs(Y - anotherPoint.Y); return(dx <= 1 && dy <= 1); }
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)); }
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); }
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)); }
public bool IsOrthogonalNeighborOrEqual(IReadOnlyPointInt32 anotherPoint) { return((X == anotherPoint.X && Y == anotherPoint.Y) || IsOrthogonalNeighbor(anotherPoint)); }
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))); }
public PointInt32(IReadOnlyPointInt32 point) { m_X = point.X; m_Y = point.Y; }
public static IEnumerable <PointInt32> GetOrthogonalAdjectedCoordinates(IReadOnlyPointInt32 coordinates) { return(GetOrthogonalAdjectedCoordinates(coordinates, 1)); }
public double Distance(IReadOnlyPointInt32 stop) { int dx = stop.X - X; int dy = stop.Y - Y; return Math.Sqrt(dx * dx + dy * dy); }
public static IEnumerable<PointInt32> GetOrthogonalAdjectedCoordinates(IReadOnlyPointInt32 coordinates) { return GetOrthogonalAdjectedCoordinates(coordinates, 1); }
public bool IsOrthogonalNeighborOrEqual(IReadOnlyPointInt32 anotherPoint) { return (X == anotherPoint.X && Y == anotherPoint.Y) || IsOrthogonalNeighbor(anotherPoint); }
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)); }
public bool IsNeighbor(IReadOnlyPointInt32 anotherPoint) { int dx = Math.Abs(X - anotherPoint.X); int dy = Math.Abs(Y - anotherPoint.Y); return dx <= 1 && dy <= 1; }