Advertisement
Guest User

PointInConvexPolygon

a guest
Jul 6th, 2012
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1.  
  2. int PointInConvexPolygon(Point p, int n, Point v[])
  3. {
  4. int low = 0, high = n;
  5. do {
  6. int mid = (low + high)/2;
  7. if (TriangleIsCCW(v[0], v[mid], p))
  8. low = mid;
  9. else
  10. high = mid;
  11. }
  12. while (low + 1 < high);
  13.  
  14. if (low == 0 || high == n) return 0;
  15.  
  16. return TriangleIsCCW(v[low], v[high], p);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement