Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!newsfe09.iad.POSTED!7564ea0f!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Organization: Canada Eat The Cookie Foundation
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: sorting, 2D vector, puzzle piece shaped
References: <gfk6hl$snc$1@fred.mathworks.com>
In-Reply-To: <gfk6hl$snc$1@fred.mathworks.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 21
Message-ID: <uIiTk.5561$Dw1.3602@newsfe09.iad>
NNTP-Posting-Host: 24.79.146.116
X-Complaints-To: internet.abuse@sjrb.ca
X-Trace: newsfe09.iad 1226684314 24.79.146.116 (Fri, 14 Nov 2008 17:38:34 UTC)
NNTP-Posting-Date: Fri, 14 Nov 2008 17:38:34 UTC
Date: Fri, 14 Nov 2008 11:38:54 -0600
Xref: news.mathworks.com comp.soft-sys.matlab:500864


Mahdieh 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 points in the
> vector, I would get the permieter of the shape. i.e. consequent points in the vector,
> correspond to adjacent point in the graph. 

In theory, this should work:

xm = mean(XY,1); ym = mean(XY,2);
t = complex(xm, ym) + sort(complex(XY(:,1) - xm, XY(:,2) - ym)));
plot(real(t[1:end 1]), imag(t[1:end 1]))

This is just another way of expressing a centroid method like you mentioned.

-- 
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?