"nearest point" between the points of two spreads

I have a problem with the “nearest point” between the points of two spreads.
So for example i have cricle with 20 points and i have a spread with
20 random points.
And now i want to connect this random points to the nearest
How I can do this?
So something with points2vector and sorting the length, but
i don’t know how to do this with two spreads.

thanks alot

Cross (2d) will help getting you the 20x20=400 combinations which you would need to test.

Can you explain me how to build these, please.
At the moment i’m not able to solve my problem.
Now I’m trying a recursiv method, but i think its
more dirty and slower than the way with a cross.
But it will be a heavy calculation when the spreads
have both about 200 points…


Your problem is a bit simulair to a Multiple fingers and multiple objects of a multitouchscreen. Tonfilm explained it very good here.

This means you have to check each point off your circle, with each point off the randomspread. For 20x20 values, this means you are dealing with 400 values, and 200 points is 40000 calculations!!

edit: I have tried to patch you something but when 1 random point is closer to more points off the circular spread, well, you end up with some random points not connected to any circle, or the other way arround, what you prefer…

edit2: and ere is the patch…

FindClosests.v4p (34.3 kB)