#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 110;
const double eps = 1e-8;
const double PI = 3.1415926535898;
struct point
{
double x,y;
}s[N],t[N];
bool isZero(double x)
{
return (x>0?x:-x)<eps;
}
double dis(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
//叉积
double crossProd(point a,point b,point c)
{
return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
}
//以最左下的点为基准点,其他各点(逆时针方向)以极角从小到大的排序规则
int cmp(const void * a,const void * b)
{
point *c = (point *)a;
point *d = (point *)b;
double k = crossProd(t[0],*c,*d);
if(k<eps||(isZero(k) && (dis(t[0],*c)>dis(t[0],*d))))
return 1;
return -1;
}
double Graham(int n) {
double x = t[0].x;
double y = t[0].y;
int k = 0;
for (int i
求凸包的周长(计算几何模板)
最新推荐文章于 2020-04-20 20:08:31 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)