I am developing a web app and I need to find a way to draw an outline rectangular polygon connecting the given points to form a perimeter on a coordinate system.
I found this ordering shuffled points that can be joined to form a polygon (in python) to be quite relevant to my problem, but it has the problem that, if any points surpasses the center of the polygon the algorithm does not work...
To make it more clear what I want I am attaching two pictures to show what I want to achieve with given points:
Correct way to join points
Wrong way to connect points
Is there an algorithm that given point coordinates creates the rectangular perimeter as I want it? Thanks