Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Convex(vector<Point> vector_of_points)
- {
- int i, j, k;
- int flag = 0;
- double z;
- if (vector_of_points.size() < 3)
- return(0);
- for (i = 0; i < vector_of_points.size(); i++)
- {
- j = (i + 1) % vector_of_points.size();
- k = (i + 2) % vector_of_points.size();
- z = (vector_of_points[j].x - vector_of_points[i].x) * (vector_of_points[k].y - vector_of_points[j].y);
- z -= (vector_of_points[j].y - vector_of_points[i].y) * (vector_of_points[k].x - vector_of_points[j].x);
- if (z < 0)
- flag |= 1;
- else if (z > 0)
- flag |= 2;
- if (flag == 3) {
- cout << "\n\tConcave(вогнутый)";
- return (0);
- }
- }
- if (flag != 0)
- cout << "\n\tConvex(выпуклый)";
- else
- return(0);
- }
- void inputPoints(vector<Point> &vector_of_points)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(1, 0, 0);
- glBegin(GL_LINE_LOOP);
- int amount_of_points;
- cout << "amount of points: ";
- cin >> amount_of_points;
- for (int i = 0; i < amount_of_points; i++)
- {
- Point temp;
- cout << "point " << i + 1 << endl;
- cout << "\tinput x ";
- cin >> temp.x;
- cout << "\tinput y ";
- cin >> temp.y;
- glVertex2f(temp.x, temp.y);
- vector_of_points.push_back(temp);
- }
- glEnd();
- glFlush();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement