Crossing Prisms
Time limit1sMemory limit128 MB
Compute the surface area of the solid formed by intersecting two identical prisms (one along the x-axis, one along the y-axis) whose cross section is a given simple polygon.
- Level
Hard9 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
A mathematician who is also a sculptor creates sculptures out of mathematics. His method is unusual: he takes two identical prisms, crosses them at right angles, and keeps their intersection as a new polyhedron. Because he finishes each piece with paint, he needs the surface area of the polyhedron to estimate how much pigment is required.
For example, two particular identical prisms crossed at right angles produce an intersection whose surface area is approximately 194.8255.
Given the shape of the common cross section of the two identical prisms, compute the surface area of the resulting sculpture.
Input
The input consists of multiple datasets, followed by a single line containing only a zero. The first line of each dataset contains an integer , the number of the following lines; each of those lines contains two integers and ().
The closed path formed by the points is the outline of the cross section of the prisms. This closed path is simple: it neither crosses nor touches itself. The right-hand side of the directed segment from to is the inside of the section.
You may assume that , , and ().
One prism is placed along the -axis so that the outline of its cross section at is given by the points (, ). The other prism is placed along the -axis so that its cross section at is given by the points (, ).
Output
For each dataset, print a single line containing the surface area of the polyhedron defined by that dataset, rounded to exactly four digits after the decimal point.