标签:amp min ret 线段 模板 bool cti ons point
const double eps=1e-8; struct point{ double x,y; void input(){ scanf("%lf%lf",&x,&y); } }; struct segment{ point a,b; void input(){ a.input(); b.input(); } double direction(point p1,point p2,point p3){ return (p2.x-p1.x)*(p3.y-p2.y) - (p3.x - p2.x)*(p2.y - p1.y); } bool judge(segment u){ if(min(a.y,b.y)>max(u.a.y,u.b.y))return 0; if(max(a.y,b.y)<min(u.a.y,u.b.y))return 0; if(min(a.x,b.x)>max(u.a.x,u.b.x))return 0; if(max(a.x,b.x)<min(u.a.x,u.b.x))return 0; double d1 = direction(a,b,u.a); double d2 = direction(a,b,u.b); double d3 = direction(u.a,u.b,a); double d4 = direction(u.a,u.b,b); return (d1*d2<eps&&d3*d4<=eps); } }
标签:amp min ret 线段 模板 bool cti ons point
原文地址:https://www.cnblogs.com/llhsbg/p/12923011.html