Find the closest point in a point cloud in a near equivalent point cloud I'm having a hard time wrapping my head around an algorithm, and not really sure if such a problem is known, common and possibly named, or if this is somewhat unique.
I have 2 different clouds of points (2D). I need to generate an index map from one to the other by proximity. Points that are closest should map to each other. This part isn't that hard.
The hard part is that each &quot;to&quot; point should only be used by one &quot;from&quot; point.
For example, let's say these are my &quot;from&quot; points: ([x, y] // index)
[
  [1, 10],  // 0
  [10, 10], // 1
  [19, 10], // 2
]

And these are my &quot;to&quot; points:
[
  [11, 10], // 0
  [9, 10],  // 1
  [10, 10], // 2
]

Then I would expect the following index mapping (fromIndex: toIndex)
{
  0: 1, // [1,10] -&gt; [9,10]
  1: 2, // [10,10 -&gt; [10,10]
  2: 0, // [19,10] -&gt; [11,10]
}

In this example, all three new points are closest to [10,10], but...

The new point [10,10] (index 2) is zero distance from to old point [10,10] (index 1), so it just be assigned that index.
The new point [11,10] (index 0) is 1 distance to the old point [10,10] (index 1), and 8 distance from the old point [19,10] (index 2). index 1 is closest, but since another point is closer, the second closest point is chosen (index 2).

Finding the closest point is easy, but how would I go about finding the closest point that doesn't also have another point that's even closer, and so it should find the next closest point, which also doesn't have another point closer to that, and if does find the next closest point which... (did I go recursive?)
And obviously this would be run on point clouds of large number (up to about a max of about 50,000 at the moment)
How would I go about developing this algorithm?
This problem is known as Euclidean minimum cost perfect matching, I have linked a survey by Sayan Bhattacharya that contains various references to algorithms, both exact and approximations.
If you wish to solve this problem for $n \approx 50000$, I would skip the exact solutions entirely and go straight to the approximations.