mercredi 9 août 2023

How does C++ sort an unordered list of rows, aiming for optimal continuity?

I have a bunch of unorganized line segments, and I need to reorder them with the goal of most continuity, which can be based on the end point of the line segment versus the start point of the next line segment as a sorting rule. What algorithms can I refer to please?

In a case like the following, the starting line does not specify which one to start with, as long as the continuity of the line is good

https://img1.imgtp.com/2023/08/09/O0BZNRJo.png

I've tried traversing each segment to make a judgment, but there's no good way to find out where the segments start based on comparisons made from the first segment in the list, or to deal with multiple, separate, consecutive segments.

Aucun commentaire:

Enregistrer un commentaire