Skip to content

Instantly share code, notes, and snippets.

@boboboa32
Created October 11, 2012 14:20
Show Gist options
  • Select an option

  • Save boboboa32/3872672 to your computer and use it in GitHub Desktop.

Select an option

Save boboboa32/3872672 to your computer and use it in GitHub Desktop.
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