The polygon above is actually a collection of a lot of black points closely packed together. I want to approximate these black points as straight line segments. The black points are not sorted in any order.
What I’m doing right now is sort these points by selecting any random black point and recursively finding the next closest point until no more points are left, the problem with this method is it might produce inaccurate results, if there is a small gap of points somewhere on the shape or dense lump of points somewhere on the shape. After sorting the points by this algorithm I run Douglas–Peucker algorithm to obtain the line segments. Am I doing it right? How can I approach this problem better?