Example #1
0
 public static IEnumerable <Location> Inside
     (this IEnumerable <Location> source, MapSize size)
 {
     return(source
            .Where(location => location.IsInside(size)));
 }
Example #2
0
 public Location AboveDiagonal(MapSize size)
 {
     return(IsAboveDiagonal(size) ? this : DiagonalMirror(size));
 }
Example #3
0
 /// <summary>
 /// Yields only indices that are lying inside of a triangle with
 /// sides produced by lines: X = 0; Y = 0; X / size.X + Y / size.Y = 1
 /// </summary>
 public static IEnumerable <Location> InsideAndAboveDiagonal
     (this IEnumerable <Location> source, MapSize size)
 {
     return(source
            .Where(location => location.IsInside(size) && location.IsAboveDiagonal(size)));
 }
Example #4
0
 public bool IsBelowDiagonal(MapSize size)
 {
     return(Y > size.Y - (float)X / size.X * size.Y - 1);
 }
Example #5
0
 public bool IsOnDiagonal(MapSize size)
 {
     return(!IsAboveDiagonal(size) && !IsBelowDiagonal(size));
 }
Example #6
0
 public bool IsAboveDiagonal(MapSize size)
 {
     return(Y < size.Y - (float)X / size.X * size.Y - 1);
 }
Example #7
0
 public bool IsInside(MapSize size)
 {
     return(X >= 0 && X < size.X && Y >= 0 && Y < size.Y);
 }
Example #8
0
 public Location DiagonalMirror(MapSize size)
 {
     return(IsOnDiagonal(size)
         ? X < size.X / 2 ? this : new Location(size.Y - Y - 1, size.X - X - 1)
         : new Location(size.Y - Y - 1, size.X - X - 1));
 }
Example #9
0
 public static Location Max(MapSize size)
 {
     return(new Location(size.Y - 1, size.X - 1));
 }
Example #10
0
 /// <summary>
 /// Yields only indices that are lying inside of a triangle with
 /// sides produced by lines: X = 0; Y = 0; X / size.X + Y / size.Y = 1
 /// </summary>
 public static IEnumerable <SigmaIndex> Clamp(this IEnumerable <SigmaIndex> source, MapSize size)
 {
     return(source
            .Where(index => index.IsInside(size) && index.IsAboveDiagonal(size)));
 }