计算几何之凸包(一) {卷包裹算法}
http://www.cnblogs.com/Booble/archive/2011/02/28/1967179.html#3229390
计算几何之凸包(二) {更高效的算法}
http://www.cnblogs.com/Booble/archive/2011/03/10/1980089.html计算几何之凸包(三) {旋转卡壳初步}
http://www.cnblogs.com/Booble/archive/2011/04/03/2004865.html
快速凸包
QuickHull
#include <iostream>
#include <math.h>
#define maxn 100000
#define zero 1e-12
#define sgn(x) (fabs(x)<zero?0:(x>0?1:-1))
#define cross(a,b,c) ((b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x))
#define cmp(a,b) (a.x<b.x || sgn(a.x-b.x)==0 && a.y<b.y)
using namespace std;
struct point{
double x,y;
}p[maxn];
double s[maxn];
void hull(int l,int r,point a,point b){
int x=l,i=l-1,j=r+1,k;
for (k=l;k<=r;k++){
double temp=sgn(s[x]-s[k]);
if (temp<0 || temp==0 && cmp(p[x],p[k])) x=k;
}
point y=p[x];
for (k=l;k<=r;k++){
s[++i]=cross(p[k],a,y);
if (sgn(s[i])>0) swap(p[i],p[k]); else i--;
}
for (k=r;k>=l;k--){
s[--j]=cross(p[k],y,b);
if (sgn(s[j])>0) swap(p[j],p[k]); else j++;
}
if (l<=i) hull(l,i,a,y);
printf("%.4lf %.4lf\n",y.x,y.y);
if (j<=r) hull(j,r,y,b);
}
int main(){
freopen("CH2D.in","r",stdin);
freopen("CH2D1.out","w",stdout);
int n,i,x=0;
scanf("%d",&n);
for (i=1;i<=n;i++){
scanf("%lf %lf",&p[i].x,&p[i].y);
if (x==0 || cmp(p[i],p[x])) x=i;
}
swap(p[1],p[x]);
printf("%.4lf %.4lf\n",p[1].x,p[1].y);
hull(2,n,p[1],p[1]);
return 0;
}