2bc*cosa=b^2+c^2-a^2
/*First spit out the groove of the range of the value of π Konjac Konjac said that really did not think of how to find the intersection of the situation, I want to seek the intersection, in fact, calculate the area of the banana can be sector minus the triangle*/#include<cstdio>#include<cstdlib>#include<cmath>#include<iostream>#include<algorithm>Const DoublePi=3.14159265358979323846264;using namespacestd;voidWork () {DoubleX1,Y1,R1,X2,Y2,R2; scanf ("%LF%LF%LF%LF%LF%LF",&x1,&y1,&r1,&x2,&y2,&R2); DoubleD=SQRT (ABS (X1-X2) *abs (x1-x2) +abs (y1-y2) *abs (y1-y2)); if(R1+r2<=d)// to { Doubleans=r1*r1*pi+r2*r2*Pi; printf ("%.3lf\n", ans); return; } if(R1+r2>d&&abs (R1-R2) >=d)//included { DoubleAns=max (R2,R1) *max (R2,R1) *Pi; printf ("%.3lf\n", ans); return; } //intersect Doubleans=r1*r1*pi+r2*r2*Pi; DoubleJ1=acos ((D*D+R1*R1-R2*R2)/(2*d*R1)); DoubleJ2=acos ((D*D+R2*R2-R1*R1)/(2*d*r2)); Ans-= (r1*r1*j1+r2*r2*J2); Ans+=d*r1*sin (J1); printf ("%.3lf\n", ans);}intMain () {Freopen ("jh.in","R", stdin); //freopen ("standing.in", "R", stdin); //freopen ("Standing.out", "w", stdout); intT;SCANF ("%d",&T); while(t--) {work (); } return 0;}
View Code
Stand Military Posture