@daniel.c wrote:
Hello,
I’m writing C# script in grasshopper. I want to sort points along polyline and create new polyline that goes trough sorted points. I came up with following code:
Point3d[] sort_pts= culled_pts; double[] angles = new double[sort_pts.Length]; for (int i = 0; i < sort_pts.Length; i++) { angles[i] = Math.Atan2(sort_pts[i].Y, sort_pts[i].X); } Array.Sort(angles, sort_pts); List<Point3d> final_pts = new List<Point3d>(sort_pts); Polyline final_top_poly = new Polyline(final_pts);
The problem is, that if the points Y coordinates are all 0 it breaks and doesnt work. It works if X coordinates are 0 and the rest of combination of coordinates… Any ideas why?
I appreciate the help, thanks.Dan.
Posts: 2
Participants: 2