Path: news.mathworks.com!not-for-mail
From: "Mahdieh" <mahdieh.emrani@capitalhealth.ca>
Newsgroups: comp.soft-sys.matlab
Subject: Re: sorting, 2D vector, puzzle piece shaped
Date: Fri, 14 Nov 2008 18:22:02 +0000 (UTC)
Organization: Glenrose Research Building
Lines: 42
Message-ID: <gfkfka$su8$1@fred.mathworks.com>
References: <gfk6hl$snc$1@fred.mathworks.com> <cfb67021-f6d7-4853-b3bb-52e1211a087a@a3g2000prm.googlegroups.com>
Reply-To: "Mahdieh" <mahdieh.emrani@capitalhealth.ca>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1226686922 29640 172.30.248.35 (14 Nov 2008 18:22:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 14 Nov 2008 18:22:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1449772
Xref: news.mathworks.com comp.soft-sys.matlab:500876


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:
> > 1- =A0a. calculating the centroid, b. choosing one point in the vector c.=
>  sorting based on the angle between two lines, one passing through centroid=
>  and b.point, other line passing through centroid and any point on the vect=
> or ...
> >
> > 2- a. dividing the shape into 4 quadrants, b. sorting each quadrant based=
>  on X or Y c. connecting them together
> >
> > none of the methods, accomplish sorting the whole shape ...
> >
> > I am out of algorithms,
> > any help would be really appreciated ...
> >
> > Thanks a lot
> > -Mah
> 
> ----------------------------------------------------------
> 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

well, I need them sorted for my further analysis. I know that I get a perfect plot by just using the plot function. but what I need , is that the vector is sorted, in such way that the 1st and 2nd elements correspond to 2 consequent points on the graph ... and so on for the rest of my vector ... 

any help is really appreciated.
Thanks,