Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: sorting, 2D vector, puzzle piece shaped
Date: Fri, 14 Nov 2008 17:40:17 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 36
Message-ID: <gfkd60$q5a$1@fred.mathworks.com>
References: <gfk6hl$snc$1@fred.mathworks.com> <cfb67021-f6d7-4853-b3bb-52e1211a087a@a3g2000prm.googlegroups.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1226684417 26794 172.30.248.38 (14 Nov 2008 17:40:17 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 14 Nov 2008 17:40:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:500865


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <cfb67021-f6d7-4853-b3bb-52e1211a087a@a3g2000prm.googlegroups.com>...
> On Nov 14, 10:47=A0am, "Mahdieh" <mahdieh.emr...@capitalhealth.ca>
> wrote:
> > I have a nx2 vector, which includes the XY coordinates of the n points.
> >
> > When plotted, these points create a shape looking like a puzzle piece.
> > Now, I need to sort this vector, such that by connecting two consequent p=
> oints in the vector, I would get the permieter of the shape. i.e. consequen=
> t points in the vector, correspond to adjacent point in the graph.
> >
> > I have tried:

(Snip)

> ----------------------------------------------------------
> Mah:
> Not sure why you're having such difficulty.  Just add a pair of
> elements at the end of the array that are the same as the first
> coordinate of the array (so you'll get a closed curve), and use the
> plot command.  It's quite capable of plotting a closed curve such as a
> jigsaw puzzle piece.  Why do you need to do sorting????
> Regards,
> ImageAnalyst

Because, I predict the points are scattered. The OP does
not have a polygon, only a list of scattered points, in no
specific order.

The simplest solution is to use one of the traveling salesman
codes that Joseph Kirk has posted to the file exchange. In
fact, he has codes that assume the start and end points
must be the same, as required for a closed polygon. The
TSP code will produce a polygon as the OP desires.

HTH,
John