Closest Points in RhinoCommon/C#

To find the (distance to the) closest point in a collection of points, you’d have to do something like this:

double minDistance = double.MaxValue;
for (int i = 0; i < points.Count; i++) 
// you could also use a foreach loop if you don't care about indices)
{
  double localDistance = locus.DistanceTo(points[i]);
  minDistance = Math.Min(minDistance, localDistance);
}
return minDistance;

However in RhinoCommon this functionality is readily available from the Point3dList class as ClosestIndex, ClosestIndexInList and ClosestPointInList. The latter two methods are static, meaning you can use them on other collections, such as List<Point3d>, Point3d[], ImmutableArray<Point3d>, etc.

Best to stay away from PointClouds in Grasshopper.