Grasshopper

algorithmic modeling for Rhino

# Pairs of Closest Points

Hello,

I have two lists of points. Each of the two has 20 points, so 40 in total.

I want to create such 20 lines in between them that they are of the closest pair combination possible. Yet they should not have common start or end points. So each line should be unique in terms of two end point coordinates.

Is this possible? Pairing each point in list A with another in B in this manner?

Thank you,

Levent

Views: 1880

Attachments:

### Replies to This Discussion

Hi.

You might want to apply simple loop algorithm to your task.

Attached is an example using "Anemone" plug-in.

Attachments:

Thank you very much, this helps a lot!

I was wondering if the following could be achieved with a similar manner;

I have to sets of curves - each set indicating a specific territory  -. I want to connect these curves' end points with minimum obstruction in the central space.

I tried to do it manually; green and purple are my sets of curves and blue is kind of what I am trying to do. I realise there are not equal number of blue lines with green and purple but that is fine as long as the script does what I tried to do manually which is drawing lines around the perimeter and between end points of list A and B.

Attachments:

I think this is a case quite different from what you initially thought.
And the solution with my Anemone depends on the order of your list. This is because it sequentially identifies and removes items one by one and produces the final result.
The attached file is a bit of an adjustment to your case, but it will not be a perfect solution.

(Try seed variations grouped "red".)
What you want is that the end points of the two pairs of curves are connected as closely as possible to each other in a similar position and must be unique.
Making an algorithm that satisfies these conditions using GH 's native can be very troublesome.
IMHO, you might want to ask for a solution using Scripting (C # or python).

Attachments:

the closest pair combination possible

Referring to the original question, not the second one about the curves, this would be the minimum possible sum ('MA') of line lengths, right?  Hyungsoo Kim's solution totals 577.98:

This one (attached) yields a sum of 561.4.  The difference is that each time through the loop, I choose the shortest pair, removing those two points from further consideration:

Hyungsoo Kim's result:

My result:

Attachments:

• View All