0

I have a series of points whose coordinates are as follows

pts_x = 3   4   5   6   7   8   2   3   8   9   2   9   2   9   2   9   2   9   2   3   8   9   3   4   5   6   7   8
pts_y = 2   2   2   2   2   2   3   3   3   3   4   4   5   5   6   6   7   7   8   8   8   8   9   9   9   9   9   9

If I directly connect them following the current order, I get

enter image description here

But actually, I need a polygon. In order to re-ordere the points so that connecting them gives me a closed polygon, I come up with a solution that sorts the points in such a way that only one of x and y coordinates differs between two adjacent points.

How should I do this? I am in MATLAB.

Sibbs Gambling
  • 19,274
  • 42
  • 103
  • 174

0 Answers0