Guest User

PointInConvexPolygon

a guest
Jul 6th, 2012
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data