No BSD License  

Highlights from
Points Inside polygone

2.0

2.0 | 2 ratings Rate this file 1 Download (last 30 days) File Size: 1.67 KB File ID: #6311
image thumbnail

Points Inside polygone

by Per Sundqvist

 

17 Nov 2004 (Updated 22 Nov 2004)

Finds those points (xi,yi) who are inside the polygon, defined by the vectors (x,y)

| Watch this File

File Information
Description

Find those points (xi,yi) who are inside the polygone defined by the vectors (x,y).

Syntax: [xin,yin,Ind]=Inside(X,Y,xi,yi)

where Ind is the index of (xi,yi) that are inside the polygone
 
Example:
  
  %--- create polygone (x,y)
  phi=linspace(0,2*pi,50);
  X=(1+0.2*sin(6*phi)).*cos(phi);
  Y=(1+0.2*sin(6*phi)).*sin(phi);
  %--- random points (xi,yi)
  Nr=20;
  xi=randn(1,Nr);yi=randn(1,Nr);
  [xin,yin,Ind]=Inside(X,Y,xi,yi);
  %--- plot
  plot(X,Y,X,Y,'.',xi,yi,'ro',xin,yin,'b.');axis equal;

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
22 Nov 2004 gok gok

its not working with number of points more then 200. Did crashed with 2000 points at line 46:
dotpr=dot([Dxic;Dyic;0*Dxic],norm(:,CInd));

22 Nov 2004 Urs Schwarz (us)

per, what exactly is the difference to ML's generic inpolygon?
best
urs

25 Jan 2006 John D'Errico

This code does not do what it claims. Rather than find points inside a polygon, it approximates the polygon with 300 points along a spline fit, then tries to find points inside that boundary. The spline fit chosen is a poor one, not based on arc length, but assuming the points on the polygon are equidistant from their neighbors. It will be very slow for larger sets of points, even crashing for reasonable sets of data. Use inpolygon from matlab itself instead.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
approximation Per Sundqvist 22 Oct 2008 07:35:55
interpolation Per Sundqvist 22 Oct 2008 07:35:55
2d contour Per Sundqvist 22 Oct 2008 07:35:55
random Per Sundqvist 22 Oct 2008 07:35:55
find Per Sundqvist 22 Oct 2008 07:35:55
polygon Per Sundqvist 22 Oct 2008 07:35:55

Contact us at files@mathworks.com