Advertisement
stream13

convex polygon

Sep 14th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
  2. {
  3.   int i, j, c = 0;
  4.   for (i = 0, j = nvert-1; i < nvert; j = i++) {
  5.     if ( ((verty[i]>testy) != (verty[j]>testy)) &&
  6.        (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
  7.        c = !c;
  8.   }
  9.   return c;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement