How to sort GPS points in clockwise direction (non convex shape!)

58 Views Asked by At

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

0

There are 0 best solutions below