struct point
{
double x,y;
};
double cross(double x1,double y1,double x2,double y2)//计算叉积
{
return (x1*y2-x2*y1);
}
double compare(point k,point a,point b)
{
return cross((a.x-k.x),(a.y-k.y),(b.x-k.x),(b.y-k.y));
}
bool cmp(point a,point b) //叉积大于零是顺时针,否则是逆时针
{
point c;//选定的极坐标系的原点
c.x = 0;
c.y = 0;
if(compare(c,a,b)==0)
return a.x<b.x;
else return compare(c,a,b)>0;
}
标签:compare,return,point,double,极角,关于,y1,排序
From: https://www.cnblogs.com/Eternal-QX/p/16886245.html