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; }
时间: 2024-10-23 08:47:06