#define PI 3.141592654 #define eps 1e-8 double getdis(int x1,int y1,int x2,int y2){ return sqrt((double)(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); } double getarea(int x1,int y1,double r1,int x2,int y2,double r2){ double d=getdis(x1,y1,x2,y2); if(r1+r2<d+eps) return 0; if(d<fabs(r1-r2)+eps){ double r=min(r1,r2); return PI*r*r; } double x=(d*d+r1*r1-r2*r2)/(2*d); double t1=acos(x/r1); double t2=acos((d-x)/r2); return r1*r1*t1+r2*r2*t2-d*r1*sin(t1); }
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-23 22:34:02