#include"Queue.h" static void PT_detec(long double x ,long double y ,long double z ); static bool intersect(QueueElementType a, QueueElementType b); static bool intersect(QueueElementType a, square_A b); static bool inter(QueueElementType a, QueueElementType b); static long double area_nonself(QueueElementType a[]); extern unsigned int num_d;void PT_detec(long double x, long double y, long double r){ if(r<r0) return ; else { sum+=4; for(int k1=0;k1<=1;k1++) for(int k2=0;k2<=1;k2++) { QueueElementType w; w.x=x+pow(-1.0,k1)*r/2; w.y=y+pow(-1.0,k2)*r/2; w.r=r/2; int flag1=0; int flag2=0; for(int i=0;i<NS;i++) { if(intersect(w,self[i])) { flag1=1; if(inter(w,self[i])) { flag2=1; break; } } } if(flag1==0){ detector.push_back(w); s_all+=4*w.r*w.r; } else{ if(0==flag2) { EnQueue(p1,w); } } } }}bool intersect(QueueElementType a, QueueElementType b){ if((a.x-a.r)>(b.x+b.r)||(a.x+a.r)<(b.x-b.r)) return false; else if((a.y-a.r)>(b.y+b.r)||(a.y+a.r)<(b.y-b.r)) return false; else if((b.x<a.x+a.r)&&(b.x>a.x-a.r)) return true; else if((b.y<a.y+a.r)&&(b.y>a.y-a.r)) return true; else { if(b.x<a.x) a.x=a.x-a.r; else a.x=a.x+a.r; if(b.y<a.y) a.y=a.y-a.r; else a.y=a.y+a.r; if(sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))>b.r) return false; else return true; } }bool intersect(QueueElementType a, square_A b){ if((a.x-a.r)>b.x||(a.x+a.r)<b.x) return false; else if((a.y-a.r)>b.y||(a.y+a.r)<b.y) return false; else return true;}bool inter(QueueElementType a, QueueElementType b) { long double d; d=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); if((b.r-d)>=(a.r*sqrt(2.0))) return true; else return false;}static long double area_nonself(QueueElementType a[]){ long double x; long double y; long double r; int t=0; int s_num=0; while(t<100000) { t++; x=rand()/(double)(RAND_MAX+1); y=rand()/(double)(RAND_MAX+1); for(int i=0;i<NS;i++) { r=sqrt((a[i].x-x)*(a[i].x-x)+(a[i].y-y)*(a[i].y-y)); if(r<rs) { s_num++; break; } } } return (100000-s_num)/(double)100000;}static long double _max(long double data[]){ double _max = 0; for(int i=0; i<n_time; i++)if(data[i]>_max)_max = data[i]; return _max;}static long double _min(long double data[]){ double _min = data[0]; for(int i=0; i<n_time; i++)if(data[i]<_min)_min = data[i]; return _min;}static long double mean(long double data[]){ double _mean = 0; for(int i=0; i<n_time; i++)_mean += data[i]; return _mean/n_time;}static long double sd(long double data[],long double mean){ double sd = 0; double tmp; for(int i=0; i<n_time; i++) { tmp = data[i]-mean; sd += tmp*tmp; } return sqrt(sd/n_time);}