//這個函數判斷點c線上段ab的左邊還是右邊,
//如果傳回值大于0在左邊,如果小于0在右邊,否則共線
double left_right(point a,point b,point c)
{
a.x-=c.x; a.y-=c.y;
b.x-=c.x; b.y-=c.y;
return a.x*b.y-a.y*b.x;
}
bool is_tu(point *p,int n)
{
if(n<4) return false;
double a,b;
a = left_right(p[0],p[1],p[2]);
for(; ++p,--n>2; a=b){
b = left_right(p[0],p[1],p[2]);
if(a*b<0)
return false;
}
return true;
}