5.0

5.0 | 3 ratings Rate this file 156 downloads (last 30 days) File Size: 9.51 KB File ID: #15410

inpoly mex file

by Sebastien Paris

 

24 Jun 2007 (Updated 05 Oct 2009)

Code covered by BSD License  

Find points inside or on the border of a polygon

Download Now | Watch this File

File Information
Description

A fast mex version of the modified inpoly function.

please run mexme_inpoly.m to compile mex file on your plateform

please run test_inpoly.m for demo

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Fast points-in-polygon test
This submission has inspired the following:
2D random paths generator integrating leg's contraints

MATLAB release MATLAB 7.5 (R2007b)
Other requirements A C compiler
Zip File Content  
Other Files inpoly.c,
license.txt,
mexme_inpoly.m,
test_inpoly.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (11)
25 Jun 2007 Darren Engwirda

Well, I guess this is what you get when you "mex" someone else's code...

This mex file is based on an old version of my "inpoly.m" function. Unfortunately for the author I've made significant improvements to the algorithm since then and a different algorithm is used in my new "inpoly.m" function.

This mex file appears to be slower than my new "inpoly.m" function by a factor of between 3 and 4 on the examples I've tested, even though I have still only coded it as a *.m file.

There is also no "help inpoly" available unless you directly open the *.c file and it also seems that the inputs are required to be transposed when compared with the original "inpoly.m" function.

As with all versions/copies of "inpoly" the point of this code is that it's faster than the MATLAB "inpolygon.m" function, especially for large inputs.

26 Jun 2007 Sébastien Paris

Yes in fact, I did this mex file a long times ago. I realized that you update the algorithm. Maybe if I had 1 hour, I'll recreate the new version of this mex-file. If not, I'll remove this submission

26 Jun 2007 Sébastien Paris

sorry for my poor english level skill ...

19 Mar 2009 Martin Podt

Very useful. On the examples I have tested, the current mex version of inpoly is about 2 times faster than the *.m file.

19 Mar 2009 Luigi Giaccari

Very fast!!! well done.

I thing I found an error in the demo file:
The second demo model is buggy: the polygon is self-interecant!!

22 Mar 2009 USTC ÁÔ

it sounds like inpoltgon.

25 Mar 2009 Korea Univ Saleh

some points are on the edges of the polygon and the function can not detect that. what is the reason?

25 Mar 2009 Sebastien Paris

Please give me an example of this bahaviour.

02 Oct 2009 John Kua

Thanks! This has been very useful on a number of projects!

One problem - the function does not handle an empty input array of [2 x 0] and crashes MATLAB. Adding a check of the input dimensionality with a warning if the input is empty and perhaps returning an empty array would be nice.

03 Oct 2009 Sebastien Paris

You are right, I'll upload a version with argument checking. Thanks

07 Oct 2009 Nicolas Billard

Very good function used on my project. Thanks.

Please login to add a comment or rating.
Updates
03 Sep 2007

New algorithm imcorporated. Speed improvement between 50% up to 100%

03 Oct 2009

- Inputs arguments checking
- Should compile with Linux/GCC

05 Oct 2009

-Inputs arguments checking
-Should compile on Linux

Tag Activity for this File
Tag Applied By Date/Time
inpoly Sebastien Paris 05 Oct 2009 12:27:54
points Sebastien Paris 05 Oct 2009 12:27:54
inside Sebastien Paris 05 Oct 2009 12:27:54
polygon Sebastien Paris 05 Oct 2009 12:27:54
utility Sebastien Paris 05 Oct 2009 12:27:54
image processing Sebastien Paris 05 Oct 2009 12:27:54
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com