Namaste All,

Where can I find how exactly does the closest point component work, as in what algo does it use and stuff like that.

Thanks.

You can for example use it to split curve with point using parameter(t) and to find the closest geometries using distance

Which closest point component? They are all in Rhinocommon per each geometry type except â€śPull Pointâ€ť which is a combination of them all + some finding closest to multiple objects magic.

Closest Point

Closest Points

Curve Closest Point

Surface Closest Point

Mesh Closest Point

Pull Point

@Michael_Pryor closest point CP (currently working with that). Side question : I read somewhere that default list matching for gh components is short list, but in case of closest point CP its cross reference, am I wrong?

Default is Longest List for all components. That has to do with data matching from the users point of view, not the algorithm underneath. Code is using loops internally not these list behaviors as you know them.

Yes, typed short list by mistake.

Closest point logic is something like this. In a loop (or multi threaded, or with an RTree) measure distance from a test point to each point in a set of points. Get the index of the shortest distance and that is the index of the closest point in the set to the test point. In code you can avoid the loop all together by using Rhinocommonâ€™s very fast Point3dList class (not to be confused with List < Point3d > ) and use what is called a closest index search.

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Collections_Point3dList_ClosestIndex.htm

In the attached def, I am matching a list which is matching 28 data items from one branch to 5 from another, so for each branch after the first 4 points it is giving me the distance of all the remaining points in a branch from the last point in the second list, How then is it giving me the correct list of closest point?Hope I was able to come across clearly.Thanks

closest point cp.gh (11.6 KB)