Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.38 KB | None | 0 0
  1. bool InPoly(int x,y; Polygon poly) {
  2.   int h := poly.size();
  3.   int j := h;
  4.   int Result := false;
  5.   for(var i=0; i < h; i++) {
  6.       if ((poly[i].y < y) && (poly[j].y >= y) || (poly[j].y < y) and (poly[i].y >= y)) &&
  7.           (poly[i].x + (y - poly[i].y) / (poly[j].y - poly[i].y) * (poly[j].x - poly[i].x) < x)
  8.           Result := !Result;
  9.       j := i;
  10.   };
  11.   return Result;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement