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 09:02:50 -0500
Organization: The MathWorks, Inc.
Lines: 45
Message-ID: <fh9mea$p6r$1@fred.mathworks.com>
References: <fh8m9n$hcb$1@fred.mathworks.com> <fh8n8i$s4v$1@fred.mathworks.com> <fh8q0r$pqi$1@fred.mathworks.com>
NNTP-Posting-Host: eddinss-lt.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1194876170 25819 172.31.57.98 (12 Nov 2007 14:02:50 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 12 Nov 2007 14:02:50 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.6 (Windows/20070728)
In-Reply-To: <HIDDEN>
Xref: news.mathworks.com comp.soft-sys.matlab:437082



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