#include "stdafx.h"
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include <iostream>
using namespace std;
struct point {
int x, y;
}P[100];
int n;//顶点个数
int judge() {
double angle = 0;//较小角的和
point a, b;
a.x = P[1].x - P[0].x; a.y = P[1].y - P[0].y;
b.x = P[n - 1].x - P[0].x; b.y = P[n - 1].y - P[0].y;
angle += acos((a.x*b.x + a.y*b.y) / (sqrt(pow(a.x, 2) + pow(a.y, 2))*sqrt(pow(b.x, 2) + pow(b.y, 2))));//第一个角角度求解
a.x = P[0].x - P[n - 1].x; a.y = P[0].y - P[n - 1].y;
b.x = P[n - 2].x - P[n - 1].x; b.y = P[n - 2].y - P[n - 1].y;
angle += acos((a.x*b.x + a.y*b.y) / (sqrt(pow(a.x, 2) + pow(a.y, 2))*sqrt(pow(b.x, 2) + pow(b.y, 2))));//最后一个角角度求解
for (int i = 1; i < n - 1; i++) {
a.x = P[i + 1].x - P[i].x; a.y = P[i + 1].y - P[i].y;
b.x = P[i - 1].x - P[i].x; b.y = P[i - 1].y - P
判断多边形凸凹
最新推荐文章于 2020-09-12 09:53:58 发布