This page is still under construction.

Parts of this page are still being built. What you see may change.

Polygon Revolution

Time limit2sMemory limit512 MB

Summary
Given a convex polygon and an axis line that may cut through it, find the volume of the solid formed by revolving the polygon around the line, within absolute error 0.1.
Level

Medium7 of 10

Topics
Geometry, Math, Implementation, Brute force
Solved
No attempts yet

Problem

Given a convex polygon with NN vertices p1,…,pNp_1, \dots, p_N and a line LL on a 2-dimensional plane. You can generate a 3-dimensional solid of revolution by the revolution of the convex polygon around the axis LL. Calculate the volume of this solid.

When the axis LL is an external line of the convex polygon, the task is much easier, because the following theorem helps. However, note that the axis may intersect the convex polygon.

The second theorem of Pappus: The volume VV of a solid of revolution generated by the revolution of a lamina about an external axis is equal to the product of the area AA of the lamina and the distance traveled by the lamina's geometric centroid xx.

V=Ad2=2πAxV = Ad_2 = 2\pi Ax

Figure 5: Sample revolutions

Input

The first line of the input is a positive integer TT, the number of test cases. The first line of each test case is a positive integer NN (2<N≤1002 < N \le 100), the number of vertices of the convex polygon. Then NN lines follow. The ii-th (1≤i≤N1 \le i \le N) line contains two real numbers XiX_i (0≤Xi≤100000 \le X_i \le 10000) and YiY_i (0≤Yi≤100000 \le Y_i \le 10000), the coordinates of the vertices of the convex polygon in clockwise order. Finally, three real numbers A,B,CA, B, C (−1000≤A,B,C≤1000-1000 \le A, B, C \le 1000) represent the equation of the axis Ax+By+C=0Ax + By + C = 0.

Output

The output consists of TT lines, one line for each test case. Each line contains one real number, the volume VV of the solid of revolution, with an error not greater than 0.10.1.

Examples1

  1. Example 1

    Input
    2
    4
    0 0
    0 1
    1 1
    1 0
    1 0 0
    4
    0 0
    0 1
    1 1
    1 0
    2 0 -1
    
    Expected output
    3.1
    0.8