标签:
double mult(point a,point b,point c)
{
return (a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y);
}
bool check(point a,point b,point c,point d) //a,b是第一条线段的两端点。c,d是第二条线段的两端点。
{
if(max(a.x,b.x)<min(c.x,d.x))
return false;
if(max(a.y,b.y)<min(c.y,d.y))
return false;
if (max(c.x,d.x)<min(a.x,b.x))
return false;
if(max(c.y,d.y)<min(a.y,b.y))
return false;
if(mult(c,b,a)*mult(b,d,a)<0)
return false;
if(mult(a,d,c)*mult(d,b,c)<0)
return false;
return true;
}
标签:
原文地址:http://www.cnblogs.com/burning-flame/p/4936384.html