'Sort a list of coordinates in c++
I'm working with a lot of coordinates x & y.
float x[6][2] =
{{204.85099999999989,289.052},{1663.8270000000005,289.052},
{1663.8270000000005,-178.308},{204.85099999999989,-178.308},
{1298.0670000000002,-178.308},{1298.0670000000002,289.052}};
And basically, they're all linked with another points in this list but they're not sorted.
All these points are the coordinates of a geometric shape. Each x and y corresponds to a point.
And I am looking for the logical order of the points. For example if I start from a random point. The next point must be the one where the x or the y correspond etc...
I want to sort the points like the image above.
I would like to know if there are existing algorithms to do this with a list of coordinates, or if you have to start from scratch. And in this case, do you have any advice for points with several segments?
UPDATE: i made a more readable example.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


