Sorting random x,y spots on circularly closed line in order to calculate properly the perimeter and the area of the polygonal shape.

2 views (last 30 days)
I want to sort random x,y spots on circularly closed line in order to calculate properly the perimeter and the area of the polygonal shape. I haved attached the images which i hope help me to be more specific:
  • random spots
  • after the unsorted line created from them
  • the sorted line from matlab which of course not help us
  • and the human sort plot that i make the sort by myself and the target sort
Is there any way to sort them like that or i need to recreate the way i was collected them and i was stored?
  5 Comments
ALEXANDROS
ALEXANDROS on 27 Feb 2023
Edited: ALEXANDROS on 27 Feb 2023
yes i was try to edited in order to be more specific but anyway... the shape of random spots plot that i showed it was an extremely example of my problem. The route that the line make the closed loop usually is only one, so the only problem is a way to sort them in order to follow a circularly line loop.

Sign in to comment.

Answers (1)

Bruno Luong
Bruno Luong on 27 Feb 2023
Formulate as TSP and solve with intlinprog as showed here
  4 Comments
John D'Errico
John D'Errico on 27 Feb 2023
Edited: John D'Errico on 27 Feb 2023
Actually, a TSP solver will not cross edges. Why not?
Suppose you have some configuration of points where you think the solution has crossed edges? Then you can always change the sequence in a way that has the edges uncrossed, AND has a lower total distance.
A TSP is the correct way to solve this problem, at least if the goal is to find the minimal polygon connecting the points.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!