判断圆和三角形是否相交 可以转化为 判断三条线段是否和圆相交
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> using namespace std; typedef long long LL; ; struct point { double x,y; point operator -(const point& rhs) { point ret; ret.x=x-rhs.x;ret.y=y-rhs.y; return ret; } double operator *(const point& rhs)//“叉乘” { return x*rhs.y-y*rhs.x; } double operator ^(const point& rhs)//“点乘” { return x*rhs.x+y*rhs.y; } }a[],o; double r; double dist(point a,point b) //求点a,b的距离 { double x=a.x-b.x,y=a.y-b.y; return sqrt(x*x+y*y); } bool seg_cir(point a,point b) //判断线段ab是否与圆o相交 { if(dist(a,o)<r-eps&&dist(b,o)<r-eps) return false; else if((r-dist(a,o))*(r-dist(b,o))<=eps) return true; else { ||((a-b)^(o-b))<) return false; double h=(a-o)*(b-o)/dist(a,b); h=fabs(h); // printf("%lf %lf\n",(b-a)*(o-a),(a-b)*(o-b)); // cout<<h<<"=========\n"; return h<r+eps; } } bool ok() { ;i<;i++) )%])) return true; return false; } int main() { int T;cin>>T; while(T--) { cin>>o.x>>o.y>>r; ;i<;i++) cin>>a[i].x>>a[i].y; if(ok()) puts("Yes"); else puts("NO"); } }