Ms. Evans is creating a new, eye-catching design for her company headquarters. She thinks the Royal Ontario Museum is really cool, so she has modeled her design after its jumbled-together look:
Specifically, the shape of the headquarters will be the union of two tetrahedra. Ms. Evans will cover the outside entirely with glass, and she wants to know how much glass she will need. What is the surface area of the headquarters?
Input Specification
The input will consist of 8 lines, each line specifying a point with 3 integer coordinates in the range . The first 4 lines describe the vertices of the first tetrahedron; the last 4 lines describe the second tetrahedron.
Output Specification
A single line containing the answer to the problem. Your answer will be considered correct if its absolute or relative error does not exceed .
Note
The input will satisfy the following conditions:
- No three of the specified points will lie on a line.
- Both tetrahedra will have positive volume.
- Let be a vertex of a tetrahedron and let be vertices of the other tetrahedron. It is guaranteed that does not lie on the plane formed by .
- Let be vertices of a tetrahedron and let be vertices of the other tetrahedron. It is guaranteed that the line passing through and does not intersect the line passing through and .
Partial Marks
In test cases worth 10% of the points, the tetrahedra will not intersect.
Sample Input 1
1 17 12
13 9 4
102 7 7
76 32 42
500 500 500
502 500 500
500 501 500
503 501 504
Sample Output 1
5122.604324
Explanation for Sample Output 1
The tetrahedra do not intersect, so the answer is the sum of their surface areas.
Sample Input 2
0 0 0
10 0 0
0 10 0
0 0 10
1 1 1
2 1 1
1 2 1
1 1 2
Sample Output 2
236.6025404
Explanation for Sample Output 2
The second tetrahedron is completely enclosed by the first tetrahedron, so the answer is the surface area of the first tetrahedron.
Sample Input 3
0 0 0
10 0 0
5 5 0
5 5 6
15 2 1
-4 10 4
-10 4 12
-3 -11 3
Sample Output 3
700.85581333
Picture for Sample Input 3
Sample Input 4
2 0 0
0 2 0
4 1 0
2 2 3
2 0 2
0 2 2
4 1 2
2 2 5
Sample Output 4
35.50054500
Comments
Michael Lee-Chin Crystal Building in Toronto, Ontario