I’m working on an ICP(iterative closest point) algorithm and am stuck at the point of finding the matching points where the sum of their distances squared is minimized.

I’m not sure of the right method and how to use it.

Essentially, I have two XYZ point sets of size M and N respectively and have computed the Euclidean distances between each point in each set. Next, where I’m stuck, is to find the pair of points such that the sum of distances squared is minimized.

I expect a result of paired points of size M.

Any tips/support is appreciated.