#line 1 "test/aoj/CGL_7_I/main.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_I"
#define ERROR 0.000001
#include <iomanip>
#include <iostream>
#line 2 "Mylib/Geometry/Float/geometry_template.cpp"
#include <cmath>
#line 4 "Mylib/Geometry/Float/geometry_template.cpp"
#include <vector>
namespace haar_lib {
template <typename T>
struct vec {
T x, y;
vec() {}
vec(T x, T y) : x(x), y(y) {}
friend auto operator+(const vec &a, const vec &b) { return vec(a.x + b.x, a.y + b.y); }
friend auto operator-(const vec &a, const vec &b) { return vec(a.x - b.x, a.y - b.y); }
friend auto operator-(const vec &a) { return vec(-a.x, -a.y); }
friend bool operator==(const vec &a, const vec &b) { return a.x == b.x and a.y == b.y; }
friend bool operator!=(const vec &a, const vec &b) { return !(a == b); }
friend bool operator<(const vec &a, const vec &b) { return a.x < b.x or (a.x == b.x and a.y < b.y); }
friend std::istream &operator>>(std::istream &s, vec &a) {
s >> a.x >> a.y;
return s;
}
};
template <typename T, typename U>
auto operator*(const vec<T> &a, const U &k) { return vec<T>(a.x * k, a.y * k); }
template <typename T, typename U>
auto operator*(const U &k, const vec<T> &a) { return vec<T>(a.x * k, a.y * k); }
template <typename T, typename U>
auto operator/(const vec<T> &a, const U &k) { return vec<T>(a.x / k, a.y / k); }
template <typename T>
using point = vec<T>;
template <typename T>
T abs(const vec<T> &a) { return sqrt(a.x * a.x + a.y * a.y); }
template <typename T>
T abs_sq(const vec<T> &a) { return a.x * a.x + a.y * a.y; }
template <typename T>
T dot(const vec<T> &a, const vec<T> &b) { return a.x * b.x + a.y * b.y; }
template <typename T>
T cross(const vec<T> &a, const vec<T> &b) { return a.x * b.y - a.y * b.x; }
template <typename T>
auto unit(const vec<T> &a) { return a / abs(a); }
template <typename T>
auto normal(const vec<T> &p) { return vec<T>(-p.y, p.x); }
template <typename T>
auto polar(const T &r, const T &ang) { return vec<T>(r * cos(ang), r * sin(ang)); }
template <typename T>
T angle(const vec<T> &a, const vec<T> &b) { return atan2(b.y - a.y, b.x - a.x); }
template <typename T>
T phase(const vec<T> &a) { return atan2(a.y, a.x); }
template <typename T>
T angle_diff(const vec<T> &a, const vec<T> &b) {
T r = phase(b) - phase(a);
if (r < -M_PI)
return r + 2 * M_PI;
else if (r > M_PI)
return r - 2 * M_PI;
return r;
}
template <typename T>
struct line {
point<T> from, to;
line() : from(), to() {}
line(const point<T> &from, const point<T> &to) : from(from), to(to) {}
};
template <typename T>
using segment = line<T>;
template <typename T>
auto unit(const line<T> &a) { return unit(a.to - a.from); }
template <typename T>
auto normal(const line<T> &a) { return normal(a.to - a.from); }
template <typename T>
auto diff(const segment<T> &a) { return a.to - a.from; }
template <typename T>
T abs(const segment<T> &a) { return abs(diff(a)); }
template <typename T>
T dot(const line<T> &a, const line<T> &b) { return dot(diff(a), diff(b)); }
template <typename T>
T cross(const line<T> &a, const line<T> &b) { return cross(diff(a), diff(b)); }
template <typename T>
using polygon = std::vector<point<T>>;
template <typename T>
struct circle {
point<T> center;
T radius;
circle() : center(), radius(0) {}
circle(const point<T> ¢er, T radius) : center(center), radius(radius) {}
};
template <typename T>
std::ostream &operator<<(std::ostream &s, const vec<T> &a) {
s << "(" << a.x << ", " << a.y << ")";
return s;
}
template <typename T>
std::ostream &operator<<(std::ostream &s, const line<T> &a) {
s << "(" << a.from << " -> " << a.to << ")";
return s;
}
template <typename T>
std::ostream &operator<<(std::ostream &s, const circle<T> &a) {
s << "("
<< "center: " << a.center << ", "
<< "radius: " << a.radius << ")";
return s;
}
} // namespace haar_lib
#line 4 "Mylib/Geometry/Float/intersect_circles.cpp"
namespace haar_lib {
namespace intersect_circles_impl {
enum class status_t { SAME,
INSIDE,
INSCRIBED,
INTERSECTED,
CIRCUMSCRIBED,
OUTSIDE };
template <typename T>
struct result {
status_t status;
std::vector<point<T>> crosspoints;
bool is_same() const { return status == status_t::SAME; }
bool is_inside() const { return status == status_t::INSIDE; }
bool is_inscribed() const { return status == status_t::INSCRIBED; }
bool is_intersected() const { return status == status_t::INTERSECTED; }
bool is_circumscribed() const { return status == status_t::CIRCUMSCRIBED; }
bool is_outside() const { return status == status_t::OUTSIDE; }
};
} // namespace intersect_circles_impl
template <typename T>
auto intersect_circles(const circle<T> &a, const circle<T> &b) {
using namespace intersect_circles_impl;
const T d = abs(a.center - b.center);
const T x = acos((a.radius * a.radius + d * d - b.radius * b.radius) / ((T) 2.0 * d * a.radius));
const T t = atan2(b.center.y - a.center.y, b.center.x - a.center.x);
if (a.radius + b.radius == d) {
return result<T>({status_t::CIRCUMSCRIBED, {a.center + polar(a.radius, t)}});
} else if (abs(a.radius - b.radius) == d) {
return result<T>({status_t::INSCRIBED, {a.center + polar(a.radius, t)}});
} else if (a.radius + b.radius > d and d > abs(a.radius - b.radius)) {
return result<T>(
{status_t::INTERSECTED,
{a.center + polar(a.radius, t + x), a.center + polar(a.radius, t - x)}});
} else if (a.radius + b.radius < d) {
return result<T>({status_t::OUTSIDE, {}});
} else if (abs(a.radius - b.radius) > d) {
return result<T>({status_t::INSIDE, {}});
}
return result<T>({status_t::SAME, {}});
}
} // namespace haar_lib
#line 4 "Mylib/Geometry/Float/area_intersection_of_circles.cpp"
namespace haar_lib {
template <typename T>
T area_of_intersection_of_circles(const circle<T> &a, const circle<T> &b) {
const auto s = intersect_circles(a, b);
auto p = s.crosspoints;
if (s.is_same()) {
return a.radius * a.radius * M_PI;
} else if (s.is_inside() or s.is_inscribed()) {
return std::min(a.radius * a.radius * M_PI, b.radius * b.radius * M_PI);
} else if (s.is_intersected()) {
T ret = 0;
auto d = abs(a.center - b.center);
{
T ang = acos((a.radius * a.radius + d * d - b.radius * b.radius) / (a.radius * d * 2.0));
ret += (ang - sin(ang * 2.0) / 2.0) * a.radius * a.radius;
}
{
T ang = acos((b.radius * b.radius + d * d - a.radius * a.radius) / (b.radius * d * 2.0));
ret += (ang - sin(ang * 2.0) / 2.0) * b.radius * b.radius;
}
return ret;
}
return 0;
}
} // namespace haar_lib
#line 4 "Mylib/Geometry/Float/double_eps.cpp"
#include <limits>
namespace haar_lib {
template <typename T, const T &eps>
struct double_eps {
using value_type = T;
private:
T value_;
public:
double_eps() : value_(0) {}
double_eps(T value_) : value_(value_) {}
auto &operator=(const double_eps &rhs) {
this->value_ = rhs.value_;
return *this;
}
auto &operator+=(const double_eps &rhs) {
this->value_ += rhs.value_;
return *this;
}
auto &operator-=(const double_eps &rhs) {
this->value_ -= rhs.value_;
return *this;
}
auto &operator*=(const double_eps &rhs) {
this->value_ *= rhs.value_;
return *this;
}
auto &operator/=(const double_eps &rhs) {
this->value_ /= rhs.value_;
return *this;
}
auto operator+(const double_eps &rhs) const { return double_eps(this->value_ + rhs.value_); }
auto operator-(const double_eps &rhs) const { return double_eps(this->value_ - rhs.value_); }
auto operator*(const double_eps &rhs) const { return double_eps(this->value_ * rhs.value_); }
auto operator/(const double_eps &rhs) const { return double_eps(this->value_ / rhs.value_); }
bool operator==(const double_eps &rhs) const { return std::abs(this->value_ - rhs.value_) < eps; }
bool operator!=(const double_eps &rhs) const { return !(*this == rhs); }
bool operator<(const double_eps &rhs) const { return this->value_ - rhs.value_ < -eps; }
bool operator<=(const double_eps &rhs) const { return this->value_ - rhs.value_ < eps; }
bool operator>(const double_eps &rhs) const { return !(*this <= rhs); }
bool operator>=(const double_eps &rhs) const { return !(*this < rhs); }
auto operator-() const { return double_eps(-(this->value_)); }
explicit operator double() const noexcept { return value_; }
explicit operator long double() const noexcept { return value_; }
friend std::ostream &operator<<(std::ostream &s, const double_eps &rhs) {
s << rhs.value_;
return s;
}
friend std::istream &operator>>(std::istream &s, double_eps &rhs) {
s >> rhs.value_;
return s;
}
friend double_eps sin(double_eps x) { return std::sin((T) x); }
friend double_eps cos(double_eps x) { return std::cos((T) x); }
friend double_eps tan(double_eps x) { return std::tan((T) x); }
friend double_eps acos(double_eps x) { return std::acos((T) x); }
friend double_eps atan2(double_eps y, double_eps x) { return std::atan2((T) y, (T) x); }
friend double_eps abs(double_eps x) { return std::abs((T) x); }
friend double_eps sqrt(double_eps x) { return std::sqrt(std::max<T>(0, (T) x)); }
};
} // namespace haar_lib
namespace std {
template <typename T, const T &eps>
class numeric_limits<haar_lib::double_eps<T, eps>> {
public:
static haar_lib::double_eps<T, eps> infinity() { return numeric_limits<T>::infinity(); }
static haar_lib::double_eps<T, eps> min() { return numeric_limits<T>::min(); }
static haar_lib::double_eps<T, eps> max() { return numeric_limits<T>::max(); }
static haar_lib::double_eps<T, eps> lowest() { return numeric_limits<T>::lowest(); }
};
} // namespace std
#line 9 "test/aoj/CGL_7_I/main.test.cpp"
namespace hl = haar_lib;
static constexpr double eps = ERROR;
using D = hl::double_eps<double, eps>;
int main() {
hl::circle<D> c1, c2;
std::cin >> c1.center >> c1.radius >> c2.center >> c2.radius;
std::cout << std::fixed << std::setprecision(12) << hl::area_of_intersection_of_circles(c1, c2) << "\n";
return 0;
}