private int[] calculateDistanceAndOrientation(int x, int y) { int dist = (int)Math.Sqrt(x * x + y * y); int pos = (int)(Math.Atan(y / (float)x) * 180.0 / Math.PI + 360); if (x < 0) pos += 180; pos %= 360; return new int[] { dist, pos }; } }