#include #define FOR(i, n) for(int i = 0; i < (n); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define TRAV(i, a) for(auto & i : (a)) #define SZ(x) ((int)(x).size()) #define X first #define Y second #define MP std::make_pair #define PR std::pair typedef long long ll; typedef std::pair PII; typedef std::vector VI; typedef long double ld; typedef std::pair PLD; const ld PI = 3.141592653589793; ld r; ld len(PLD a){ return sqrtl(a.X*a.X+a.Y*a.Y); } ld kat(PLD a, PLD b){ ld xd = acosl(std::min((ld)1.0, std::max((ld)-1.0, (a.X*b.X+a.Y*b.Y)/(len(a)*len(b))))); assert(xd >= -0.00000001); //if(xd < -0.0000001) xd += 2.0*PI; return xd; } ld kkk(PLD a, PLD b){ if(a.X*b.Y-a.Y*b.X < 0) return 2.0*PI-kat(a, b); return kat(a, b); } ld side(ld x){ if(x >= r) return 0.0; if(x <= -r) return PI*r*r; // x^2 + y^2 = r^2 // x = cos // y^2 = r^2-x^2 ld y2 = r*r-x*x; ld y = sqrtl(y2); ld troj = -y*x; if(x >= 0) return troj+0.5*r*r*kat(MP(x, y), MP(x, -y)); return troj+0.5*r*r*(2.0*PI-kat(MP(x, y), MP(x, -y))); } ld PL(PLD a, PLD b){ return 0.5*(a.X*b.Y-a.Y*b.X); } PLD py(ld x){ ld y2 = r*r-x*x; return MP(x, sqrtl(y2)); } PLD px(ld y){ ld x2 = r*r-y*y; return MP(sqrtl(x2), y); } ld corner(ld x, ld y){ if(x >= r || y >= r) return 0.0; if(x <= -r && y <= -r) return PI*r*r; if(x <= -r) return side(y); if(y <= -r) return side(x); if(x*x+y*y > r*r){ if(x > 0 && y > 0) return 0.0; if(x > 0 && y < 0) return side(x); if(y > 0 && x < 0) return side(y); return PI*r*r-side(-x)-side(-y); } PLD rig = px(y); PLD up = py(x); PLD vec = MP(x, y); ld ar = 0.5*r*r*kat(rig, up); ar += PL(vec, rig); ar += PL(up, vec); return ar; } int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed << std::setprecision(10); ld x, y, ax, ay, bx, by; std::cin >> x >> y >> r >> ax >> ay >> bx >> by; if(ax > bx) std::swap(ax, bx); if(ay > by) std::swap(ay, by); ax -= x; bx -= x; ay -= y; by -= y; ld pole = PI*r*r; pole -= side(by); pole -= side(bx); pole -= side(-ax); pole -= side(-ay); //std::cout << "sides " << PI*r*r-pole << "\n"; //ld xdddd = pole; pole += corner(bx, by); pole += corner(-ax, by); pole += corner(bx, -ay); pole += corner(-ax, -ay); //std::cout << "corners " << pole - xdddd << "\n"; std::cout << pole; return 0; }