5.0

5.0 | 5 ratings Rate this file 22 Downloads (last 30 days) File Size: 68.1 KB File ID: #15410
image thumbnail

inpoly mex file

by

 

24 Jun 2007 (Updated )

Find points inside or on the border of a polygon

| 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

This file inspired 2 D Random Paths Generator Integrating Leg's Contraints.

MATLAB release MATLAB 7.5 (R2007b)
Other requirements A C compiler such as MSVC/Intel CPP/GCC
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (13)
12 Apr 2014 Michael Dunphy

For my use case, this mex file is 1000-1500 times faster than the default inpolygon function that comes with matlab. Nicely done!

25 Feb 2011 Matthew Behrend

great! this was 50 times faster than inpoly.m for my application

07 Oct 2009 Nicolas Billard

Very good function used on my project. Thanks.

03 Oct 2009 Sebastien PARIS

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

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.

25 Mar 2009 Sebastien PARIS

Please give me an example of this bahaviour.

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?

22 Mar 2009 Zhang Yanxiang

it sounds like inpoltgon.

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!!

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.

26 Jun 2007 S├ębastien Paris

sorry for my poor english level skill ...

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

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.

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

21 Nov 2011

- Add online help
- Cosmetic changes in inpoly.c and demo file

12 May 2014

- Fix a bug (missing free)

Contact us