public static IEnumerable <Point> EnumeratePointsAtChebyshevDistance( this Point source, int distance, bool clockwise, bool orderByEuclideanDistance, Dir8 startDir = Dir8.N) { if (distance < 0) { throw new ArgumentException("distance must be nonnegative"); } if (!startDir.IsValid(false)) { throw new ArgumentException("startDir must be an orthogonal or diagonal"); } if (orderByEuclideanDistance && startDir.IsDiagonal()) { // If ordering by Euclidean distance, we'll be starting at an orthogonal direction anyway: startDir = startDir.Rotate(clockwise); } return(source.PointsAtChebyshevDistanceInternal(distance, clockwise, orderByEuclideanDistance, startDir)); }
public static IEnumerable <Point> EnumeratePointsByChebyshevDistance( this Point source, bool clockwise, bool orderByEuclideanDistance, Dir8 startDir = Dir8.N) { if (!startDir.IsValid(false)) { throw new ArgumentException("startDir must be an orthogonal or diagonal"); } if (orderByEuclideanDistance && startDir.IsDiagonal()) { // If ordering by Euclidean distance, we'll be starting at an orthogonal direction anyway: startDir = startDir.Rotate(clockwise); } for (int distance = 0; ; ++distance) { foreach (Point p in source.PointsAtChebyshevDistanceInternal(distance, clockwise, orderByEuclideanDistance, startDir)) { yield return(p); } } }