On Mar 16, 12:27 am, Ray Koopman <koop...@sfu.ca> wrote: > ... I would give the 2D coordinates to a convex hull routine. > If the hull uses all the points then it's your loop. But if > some points are inside the hull then a simple nearest-neighbor > approach can sometimes connect the points in the wrong order.
If there are points inside the hull then try inserting them into the hull sequence so as to minimize the total length of the resulting loop -- sort of a modified traveling salesman problem. You may even find code somewhere that does it.