Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool IsConvex(vector <point> &p) {
- int n = p.size();
- if (n <=1)
- {
- return true;
- }
- if (n == 2)
- {
- return false;
- }
- int state;
- int stateprev;
- int check = -1345;
- for (int i = 0; i < n; ++i)
- {
- for (int j = 0; j < n; ++j)
- {
- if (j != i && j != (i + 1) % n)
- {
- state = Classify(p[i].x, p[i].y, p[(i + 1) % n].x, p[(i + 1) % n].y, p[j].x, p[j].y);
- if (state == BEHIND || state == BETWEEN || state == BEYOND)
- {
- continue;
- }
- if (check != -1345 && check != state)
- {
- return false;
- }
- if (state == RIGHT || state == LEFT)
- {
- check = state;
- }
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement