Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: converting vertex orders counterclockwise
Date: Tue, 22 May 2012 12:14:07 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 25
Message-ID: <jpfvuf$7n3$1@newscl01ah.mathworks.com>
References: <jpemb6$qif$1@newscl01ah.mathworks.com> <jpf9i7$b6m$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1337688847 7907 172.30.248.37 (22 May 2012 12:14:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 22 May 2012 12:14:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:768585

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <jpf9i7$b6m$1@newscl01ah.mathworks.com>...
> x=randn(1,30);
> y=randn(1,30);
> 
> xmean=mean(x);
> ymean=mean(y);
> [~, i] = sort(atan2(y-ymean,x-xmean));
> x = x(i);
> y = y(i);
> 
> plot(x([1:end 1]),y([1:end 1]))
> axis equal
>  
> % Bruno
- - - - - - - - - -
  Bruno, if you have

 x = [0  1  1 -1 -1  0];
 y = [1 -3  2  2 -3  1];

do you consider the vertices along this polygon to be in counterclockwise order?  I would have thought they were, but they are not in sorted order according to your 'atan2' test.  Two of the edges move the angle with respect to the mean point (at the origin) in a descending direction.

  In his second article in this thread David makes it clear he is talking about a given polygon, rather than simply a collection of points, where he says, "I have a closed curve in 2D. Starting from a point I can go clockwise or anticlockwise."

Roger Stafford