//todo, old code had pairs...not sure what to do with these yet. add only if needed: //public static int[][] FourDirectionPairs = { new int[] { 8, 2 }, new int[] { 6, 4 } }; //public static int[][] EightDirectionPairs = { new int[] { 8, 2 }, new int[] { 9, 1 }, new int[] { 6, 4 }, new int[] { 3, 7 } }; public static IEnumerable <Dir8> Enumerate(bool clockwise, bool includeNeutral, bool orthogonalsFirst, Dir8 startDir = Dir8.N) { if (includeNeutral) { yield return(Dir8.Neutral); } if (orthogonalsFirst) { Dir4 orthoDir, diagDir; if (startDir.IsOrthogonal()) { orthoDir = (Dir4)startDir; diagDir = (Dir4)startDir.Rotate(clockwise); } else { orthoDir = (Dir4)startDir.Rotate(clockwise); diagDir = (Dir4)startDir; } for (int i = 0; i < 4; ++i) { yield return((Dir8)orthoDir); orthoDir = orthoDir.Rotate(clockwise); } for (int i = 0; i < 4; ++i) { yield return((Dir8)diagDir); diagDir = diagDir.Rotate(clockwise); } } else { for (int i = 0; i < 8; ++i) { yield return(startDir); startDir = startDir.Rotate(clockwise); } } }