#include #include #include #include using namespace std; #define EPS (1e-10) struct endpoint_t { double x; int y; }; struct line_t { double x1, x2; double a, b; }; bool near(const double &x, const double &y) { return fabs(x - y) < EPS; } int main() { int n; double r; while (cin >> n >> r) { vector e; if (n == 0 && fabs(r) <= 1e-10) { break; } for (int i = 0; i < n; i++) { endpoint_t tmp; cin >> tmp.x >> tmp.y; if (!e.empty() && e.back().y * tmp.y < 0) { endpoint_t tmp2; tmp2.x = e.back().x + (tmp.x - e.back().x) * ((double)abs(e.back().y) / (double)(abs(e.back().y) + abs(tmp.y))); tmp2.y = 0; e.push_back(tmp2); } e.push_back(tmp); } vector lo, lr; vector xs; for (int i = 1; i < e.size(); i++) { line_t tmp; tmp.a = (double)(e[i-1].y - e[i].y) / (e[i-1].x - e[i].x); tmp.b = (double)e[i-1].y - tmp.a * e[i-1].x; tmp.x1 = e[i-1].x; xs.push_back(tmp.x1); tmp.x2 = e[i].x; xs.push_back(tmp.x2); lo.push_back(tmp); tmp.a = (double)(e[i-1].y - e[i].y) / (e[i-1].x - e[i].x); tmp.b = (double)e[i-1].y - tmp.a * (e[i-1].x + r); tmp.x1 = e[i-1].x + r; xs.push_back(tmp.x1); tmp.x2 = e[i].x + r; xs.push_back(tmp.x2); lr.push_back(tmp); } sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end(), near), xs.end()); int io = 0, ir = 0; double result = 0.0; for (int i = 1; i < xs.size(); i++) { if (lo[0].x1 > xs[i-1] + EPS) { continue; } if (lr[0].x1 > xs[i-1] + EPS) { continue; } if (lo.back().x2 + EPS < xs[i]) { break; } if (lr.back().x2 + EPS < xs[i]) { break; } while (lo[io].x2 <= xs[i-1] + EPS) { io++; } while (lr[ir].x2 <= xs[i-1] + EPS) { ir++; } result += ((lo[io].a * lr[ir].a) * xs[i] * xs[i] * xs[i] / 3.0 + (lo[io].a * lr[ir].b + lr[ir].a * lo[io].b) * xs[i] * xs[i] / 2.0 + (lo[io].b * lr[ir].b) * xs[i]) - ((lo[io].a * lr[ir].a) * xs[i-1] * xs[i-1] * xs[i-1] / 3.0 + (lo[io].a * lr[ir].b + lr[ir].a * lo[io].b) * xs[i-1] * xs[i-1] / 2.0 + (lo[io].b * lr[ir].b) * xs[i-1]); } cout << fixed << setprecision(10) << result << endl; } return 0; }