permutations property

List<Direction> permutations

A list of directions that occur from mirroring this Direction in both axes.

Implementation

List<Direction> get permutations {
  List<Direction> perms = [];
  List<int> hs = h == 0 ? [0] : [h, -h];
  List<int> vs = v == 0 ? [0] : [v, -v];

  for (int h in hs) {
    for (int v in vs) {
      perms.add(Direction(h, v));
      perms.add(Direction(v, h));
    }
  }
  return perms;
}