generative modeling for Rhino
i was hoping somebody could help me with the syntax for a rhinolist sort method.
what i have is a rhinolist (called "allPoints) of Point3d's, and another point (ill call it "testPoint") what i want to do is sort the "allPoints" list by their distance to "testPoint"
so far my best guess has been...
but clearly this isnt working.
ps. im working in C#
You need to supply a sorting function in the form of an IComparer<T> which is an interface or Comparison<T> which is a delegate. There's actually a fair bit of code involved in doing this.
RhinoList however provides two additional overloads that allow you to sort using keys. So all you need to do is compute the distances as an array of doubles, then call the appropriate overload.
double distances = new double[allPoints.Count];
for (int i = 0; i < allPoints.Count; i++)
distances[i] = testPoint.DistanceTo(allPoints[i]);
//Note, this code is untested.