I have series of points extracted from a regular grid, with their X/Y coordinates. A previous algorithm (that I cannot modified!) output a list of these coordinates, but the ordering of these point is random in regard to the scope of this problem as expressed byt the following python-style notation:
[ [X_O,Y_O], [X_M, Y_M], [X_D, Y_D], ... ]
Where X Y are the X and Y coordinates of each point. I am now trying to "order" them with the following logic (from point A to point R on the grid visualisation):
[ [X_A,Y_A], [X_B, Y_B], [X_C, Y_C], ... ]
The final aim being to plot a profile with the actual value on the Z grid. I have tried a "hacky" way by just identifying the neighbours of each point and ordering the one that have not been processed yet, but it is not reliable enough as I faced many artifacts.
Is there an algorithm I missed that is designed for that problem? I have done some research but I feel I am missing out something.