/// <summary> /// Returns the closest of the four non-diagonal directions inside a rectangular tilemap, by angle. /// </summary> public static Direction Quadrogonal(this Math.Direction2 direction) { return((Direction)(( (int)System.Math.Floor(direction.Degrees * (1 / 90f) + 0.5f) % 4 ) * 2 + 1)); }
/// <summary> /// Returns the closest of the eight directions inside a rectangular tilemap, by angle. /// </summary> public static Direction Octagonal(this Math.Direction2 direction) { return((Direction)((int)System.Math.Floor(direction.Degrees * (1 / 45f) + 0.5f) % 8 + 1)); }