This article explains how to use Closest Point to find closest points to specified points.


On the Grasshopper, it is represented by either of the two above.
Get points closest to specified points
Using Closest Point allows you to obtain points closest to specified points.
As an example, let’s find the points within a rectangle that is closest to the center of the rectangle from a set of randomly generated points.

Components used: ① Rectangle ② Populate 2D ③ Area ④ Closest Point

First, enter the numerical value for the length of one side into the Rectangle(X and Y).
This time, we entered 1000.
Then, as shown in the image above, a 1000×1000 rectangular line data set was created.

Next, connect the Rectangle(R) to the Populate 2D(R).
Then, enter the number of points you want to create into the Populate 2D(N).
This time, the number 10 is being entered.
Then, as shown in the image above, ten random points were created within the rectangle.

Next, connect the Rectangle(R) to the Area.
Then, the center point of the rectangle will be created.

Next, connect the Area(C) to the Closest Point(P).
Then, connect the Populate 2D to the Closest Point(C).
Then, as shown in the image above, we were able to obtain the point closest to the center point.
In this way, using Closest Point allows you to obtain the point closest to a specified point.
Data output from Closest Point
Let’s take a look at the data output from Closest Point.

Additional Components: ①Point ②List Item
Point data acquired is output from the Closest Point(P).
The Closest Point(D) outputs the numerical distance between the specified point and the acquired point.
The original index number of the acquired point data is output from the Closest Point(i).
In this case, since the number 4 is output, we can determine that the original point data with index number 4 is the one being referenced.
To verify, connect the Populate 2D to the List Item(L), and connect the value 4 to the List Item(i).

Then, we were able to retrieve the point data with index number 4.
You can see that it matches the point data closest to the center point obtained via Closest Point.
List of Grasshopper articles using Closest Point component↓




Comment