Advertisement
Guest User

point in quad

a guest
Jun 25th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1.                 int i, j, n, hit;
  2.                 outline_pt *poly;
  3.                 hit = 0;
  4.                 n    = 4;
  5.                 poly = part->outline;
  6.  
  7.                 for (i = 0, j = n - 1; i < n; j = i++) {
  8.                     if (((poly[i].y > pos.y) != (poly[j].y > pos.y)) &&
  9.                             (pos.x < (poly[j].x - poly[i].x) * (pos.y - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x))
  10.                         hit = !hit;
  11.                 }
  12.  
  13. // if hit != 0, then point is in quad.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement