Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: POLY2CW  ???  what happened to it?
Date: Mon, 12 Nov 2007 23:53:24 +0000 (UTC)
Organization: University of Memphis
Lines: 53
Message-ID: <fhap1k$1fl$1@fred.mathworks.com>
References: <fh8m9n$hcb$1@fred.mathworks.com> <fh8n8i$s4v$1@fred.mathworks.com> <fh8q0r$pqi$1@fred.mathworks.com> <fh9mea$p6r$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1194911604 1525 172.30.248.35 (12 Nov 2007 23:53:24 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 12 Nov 2007 23:53:24 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 233092
Xref: news.mathworks.com comp.soft-sys.matlab:437206



Steve Eddins <Steve.Eddins@mathworks.com> wrote in message
<fh9mea$p6r$1@fred.mathworks.com>...
> Paul wrote:
> > [snip]
> > 
> > clear
> > close('all')
> > 
> > x1 = [1/4 1/2];
> > y1 = [1/2 3/4];
> > x2 = [1/2 3/4];
> > y2 = [1/4 1/2];
> > 
> > xv = [x1,x2];
> > yv = [y1,y2];
> > 
> > 
> > 
> > 
> > x = rand(1000,1);
> > y = rand(1000,1);
> > 
> > plot(xv,yv,'ro')
> > 
> > hold on
> > plot(x,y,'g.')
> > 
> > use = inpolygon(x,y,xv,yv);
> > plot(x(use),y(use),'r.')
> > 
> > %%%%%%%%%%%%%%%%%%%%%
> > 
> > you can see that when I merge the two segments of vertices,
> > then the area I want to isolate is not correct. 
>  > [snip]
> 
> It is correct.  If you plot the polygon with lines between
the vertices, 
> like this:
> 
> plot(xv,yv,'r')
> 
> you'll see that your polygon is self-intersecting in a
kind of hourglass 
> shape.  That explains your result.
> 
> -- 
> Steve Eddins
> http://blogs.mathworks.com/steve

This is EXACTLY why I was asking about POLY2CW routine.  I
have to make the vertices of the polygon ordered clockwise.