An attempt to sort two groups of points so each point will find its closest pair in the target group, and it works like this:
- first we will reorder the target (you can do the opposite)
- test each point of the source against each point of the target and measure the distance.
- and for each iteration create an array of the distances to those points.
- sort the array so the closest distance is first.
- re order the points based on the distance
- pick it up and delete the rest.
- and so one for the rest of the points.
In case some of the points failed to find a match since all the points are take they will be deleted.
Now do the same steps for the source group.
Comments