View difference between Paste ID: urr9Qmzi and AgX68qfJ
SHOW: | | - or go back to the newest paste.
1
static void Main(string[] args)
2
        {
3
            int xpos, ypos;
4
            for (int i = 1; i <= 16; i++)
5
            {
6
                GetPos(i, out xpos, out ypos);
7
                Console.WriteLine($"{i}: x={xpos}, y={ypos}");
8
            }
9
            Console.ReadLine();
10
        }
11
12
        static void GetPos(int value, out int posx, out int posy)
13
        {
14
            value -= 1;
15
            double temp = 22.5 * (90 / 22.5 - (value % 4));
16
17
            posy = (int)Math.Round(Math.Sin(temp * Math.PI / 180) * 40);
18
            posx = (int)Math.Round(Math.Cos(temp * Math.PI / 180) * 40);
19
20
            temp = (value - value % 4) / 4.0;
21
22
            switch (temp)
23
            {
24
                case 0:
25
                    posy += 50;
26
                    posx += 50;
27
                    break;
28
                case 1:
29
                    temp = posx;
30
                    posx = posy;
31
                    posy = (int)temp;
32
                    posy *= -1;
33
                    posy += 50;
34
                    posx += 50;
35
                    break;
36
                case 2:
37
                    posx *= -1;
38
                    posy *= -1;
39
                    posx += 50;
40
                    posy += 50;
41
                    break;
42
                case 3:
43
                    temp = posx;
44
                    posx = posy;
45
                    posy = (int)temp;
46
                    posx *= -1;
47
                    posx += 50;
48
                    posy += 50;
49
                    break;
50
            }
51-
        }
51+
52
53
54
1: x=50, y=90
55
2: x=65, y=87
56
3: x=78, y=78
57
4: x=87, y=65
58
5: x=90, y=50
59
6: x=87, y=35
60
7: x=78, y=22
61
8: x=65, y=13
62
9: x=50, y=10
63
10: x=35, y=13
64
11: x=22, y=22
65
12: x=13, y=35
66
13: x=10, y=50
67
14: x=13, y=65
68
15: x=22, y=78
69
16: x=35, y=87