1

Track

I am generating a racing line for a track shown in the figure. However, I only have the unordered points for the boundaries. How should I sort all these GPS points in a clockwise direction that the vehicle can track?

Same goal as the problem here, however with a highly non-convex shape.

def rotational_sort(list_of_xy_coords):
    cx, cy = list_of_xy_coords.mean(0)
    x, y = list_of_xy_coords.T
    angles = np.arctan2(x-cx, y-cy)
    indices = np.argsort(angles)
    return list_of_xy_coords[indices]

doesn't work

Brad
  • 159,648
  • 54
  • 349
  • 530
  • Given that your points are relatively dense, maybe you could sort by the next closest point? That is, pick a point nearest the start, find two points nearest that point, measure the difference, pick the one that's the direction you want (+/- x, +/- y), and now you have your next point. Find the next closest point that isn't the previous, and now you have the next. This might not work for super tight/poorly sampled corners. – Brad Aug 07 '23 at 04:35
  • You may triangulate your points-cloud by [Marching Cubes algorithm](https://en.wikipedia.org/wiki/Marching_cubes) (not a Delaunay triangulation). Then pick the segments in the boundary and set circumferences between them. – Ripi2 Aug 07 '23 at 17:26

0 Answers0