Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- int xpos, ypos;
- for (int i = 1; i <= 16; i++)
- {
- GetPos(i, out xpos, out ypos);
- Console.WriteLine($"{i}: x={xpos}, y={ypos}");
- }
- Console.ReadLine();
- }
- static void GetPos(int value, out int posx, out int posy)
- {
- value -= 1;
- double temp = 22.5 * (90 / 22.5 - (value % 4));
- posy = (int)Math.Round(Math.Sin(temp * Math.PI / 180) * 40);
- posx = (int)Math.Round(Math.Cos(temp * Math.PI / 180) * 40);
- temp = (value - value % 4) / 4.0;
- switch (temp)
- {
- case 0:
- posy += 50;
- posx += 50;
- break;
- case 1:
- temp = posx;
- posx = posy;
- posy = (int)temp;
- posy *= -1;
- posy += 50;
- posx += 50;
- break;
- case 2:
- posx *= -1;
- posy *= -1;
- posx += 50;
- posy += 50;
- break;
- case 3:
- temp = posx;
- posx = posy;
- posy = (int)temp;
- posx *= -1;
- posx += 50;
- posy += 50;
- break;
- }
- }
- 1: x=50, y=90
- 2: x=65, y=87
- 3: x=78, y=78
- 4: x=87, y=65
- 5: x=90, y=50
- 6: x=87, y=35
- 7: x=78, y=22
- 8: x=65, y=13
- 9: x=50, y=10
- 10: x=35, y=13
- 11: x=22, y=22
- 12: x=13, y=35
- 13: x=10, y=50
- 14: x=13, y=65
- 15: x=22, y=78
- 16: x=35, y=87
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement