标签:return tor oss 线段相交 相关 sid code point type
typedef double db;
const db eps=1e-8;
int dcmp(db x){return fabs(x)<eps?0:(x<0?-1:1);}
// 2D Point && Vector
struct tp{
db x,y;
tp(){}
tp(db xx,db yy):x(xx),y(yy){}
tp(tp a,tp b):x(b.x-a.x),y(b.y-a.y){}
};
// Segment
struct tseg{
tp p1,p2;
db k;
tseg(){}
tseg(tp aa,tp bb):p1(aa),p2(bb){
// k=(aa.y-bb.y)/(aa.x-bb.x);
}
};
db cross(tp a,tp b){return b.y*a.x-b.x*a.y;} //2D
快速排斥 + 跨立实验
bool difside(tseg a,tseg b){ //b is on 2 sides of a
tp v21(a.p2,a.p1),v23(a.p2,b.p1),v24(a.p2,b.p2);
return cross(v21,v23)*cross(v21,v24)<=0;
}
bool isintersect(tseg a,tseg b){
return difside(a,b)&&difside(b,a);
}
标签:return tor oss 线段相交 相关 sid code point type
原文地址:https://www.cnblogs.com/ubospica/p/10121673.html