Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!a3g2000prm.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: sorting, 2D vector, puzzle piece shaped
Date: Fri, 14 Nov 2008 09:08:22 -0800 (PST)
Organization: http://groups.google.com
Lines: 35
Message-ID: <cfb67021-f6d7-4853-b3bb-52e1211a087a@a3g2000prm.googlegroups.com>
References: <gfk6hl$snc$1@fred.mathworks.com>
NNTP-Posting-Host: 192.44.136.113
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1226682502 1587 127.0.0.1 (14 Nov 2008 17:08:22 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 14 Nov 2008 17:08:22 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: a3g2000prm.googlegroups.com; posting-host=192.44.136.113; 
	posting-account=0rLUzAkAAABojYSRC64DkTbtiSCX77HH
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET 
	CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 
	3.5.21022),gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 bdci2px (NetCache NetApp/6.0.7)
Bytes: 2700
Xref: news.mathworks.com comp.soft-sys.matlab:500860

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