inpolygon_for_gpu

inpolygon function that works using gpuArray
312 téléchargements
Mise à jour 31 jan. 2015

Afficher la licence

This is a point-in-polygon function that can run on a gpu using large test point array sizes. It uses a simple ray-casting algorithm without pre-processing or "on" tolerance checks. Therefore it may not give the exact same results as inpolygon. Inputs must all be gpuArray objects in order to run on the gpu. The inputs take the form of MATLAB's inpolygon function. The parallel process occurs once for every vertex of the polygon, so large numbers of vertices will run slow. I had to have around around 1e5-1e7 test points to see speedup on my simple gaming GPU on a polygon with 1e4 vertices. I am hoping that re-implementing this using mex CUDA code will result in faster run-times. For best results, the number of test points should be close to the maximum array size on your GPU.
This implementation of the ray-casting algorithm is based on C code by W. Randolf Franklin, which can be found at http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

Any advice is welcome on how to speed up this algorithm, or make it more useful. Thanks!

Example:

L = linspace(0,2.*pi,6);
xv = gpuArray(cos(L)');
yv = gpuArray(sin(L)');

pts_x=gpuArray(rand(1e5,1));
pts_y=gpuArray(rand(1e5,1));

tic
in=inpolygon_for_gpu(pts_x, pts_y, xv, ,yv);
toc

Citation pour cette source

Sulimon Sattari (2024). inpolygon_for_gpu (https://www.mathworks.com/matlabcentral/fileexchange/49157-inpolygon_for_gpu), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2012b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur GPU Computing dans Help Center et MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
1.4.0.0

added more description

1.3.0.0

Clarified description

1.2.0.0

Clean up description

1.1.0.0

removed function arguments from title

1.0.0.0