Конвертировать сортировку из с++ в c#

У меня есть код сортировки на с++:

sort(points, points + n, [](point& a, point& b) {
        return atan2(a.y, a.x) < atan2(b.y, b.x); });

я пытаюсь конвертировать его на c#:

Array.Sort(points, (Point a, Point b) => 
{
    return Math.Atan2(a.y, a.x) < Math.Atan2(b.y, b.x) ? 1 : 0;
}) ;

Не могу понять как исправить проблему. Например у меня есть числа в массиве

Point[] points = new Point[1000];

такие как:

  • 3000 3000 1
  • 6000 0 2
  • 6000 2000 3
    ...
  • 0 0 0

И мне нужно, чтобы стало

  • 6000 0 2
  • 6000 2000 3
  • 3000 3000 1
  • ...
  • 0 0 0

Проблема: при работе сортировки я заметил, что она в первой итерации берет в b - элементы 0 0 0, а должна 3000 3000 1. В а берет элементы 3000 3000 1, а должна 6000 0 2. Как можно исправить проблему?

Сам код на с#:

public static long x;
        public static long y;

        struct Point
        {
            public long x, y;
            public int i;     
        }
        static long conv(double x)
        {
            return (long)(x * 1000 + 0.5 * (x >= 0 ? 0.5 : -0.5));
        }
        static bool lt(Point a, Point b) 
        {
            return a.x * b.y - a.y * b.x < 0;
        }  
        static void Main(string[] args)
        {
            int n;
            int k = 0;
            double a;
            double b;
            Point[] points = new Point[1000];
            string[] arr = Console.ReadLine().Split();
            a = int.Parse(arr[0]);
            b = int.Parse(arr[1]);
            arr = Console.ReadLine().Split();
            n = int.Parse(arr[0]);
            x = conv(a);
            y = conv(b);

            
            for (int i = 0; i < n; i++)
            {
                arr = Console.ReadLine().Split();
                double x = int.Parse(arr[0]);
                double y = int.Parse(arr[1]);
                
                points[i].i = int.Parse(arr[2]);
                points[i].x = conv(x - a);
                points[i].y = conv(y - b);
            }


            Array.Sort(points, (Point a, Point b) => 
            {
                return Math.Atan2(a.y, a.x) < Math.Atan2(b.y, b.x) ? 1 : 0;
            }) ;


            for (int i = 0; i < n - 1; i++)
            {
                if (lt(points[i], points[i + 1]))
                {
                    k = i + 1;
                }
            }

            Console.Write(0);
            Console.Write("\n");
            for (int i = 0; i < n; i++)
            {
                Console.Write(points[(i + k) % n].i);
                Console.Write("\n");
            }
            Console.Write(0);
            Console.Write("\n");
        } 

Ответы (0 шт):