Skip to content

Instantly share code, notes, and snippets.

@voycey
Created December 31, 2019 05:41
Show Gist options
  • Save voycey/3e819ac0fb4f53f198d9fb23c8abd4a5 to your computer and use it in GitHub Desktop.
Save voycey/3e819ac0fb4f53f198d9fb23c8abd4a5 to your computer and use it in GitHub Desktop.
Point in Polygon CUDA C code
int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
{
int i, j, c = 0;
for (i = 0, j = nvert-1; i < nvert; j = i++) {
if ( ((verty[i]>testy) != (verty[j]>testy)) &&
(testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
c = !c;
}
return c;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment