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)
Show older comments
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
Answers (1)
Bruno Luong
on 27 Feb 2023
Formulate as TSP and solve with intlinprog as showed here
4 Comments
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!