Ms. Evans has finally finished building her new, eye-catching company headquarters. Her design was modeled after the Royal Ontario Museum's really cool jumbled-together look:
Specifically, the shape of the headquarters is the union of two tetrahedra. Ms. Evans has already covered the outside entirely with glass, with your help calculating the amount she needed. However, now she needs to know the volume of the building (to fill the headquarters with breathable air, of course). What is the volume 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
1071.333333
Explanation for Sample Output 1
The tetrahedra do not intersect, so the answer is the sum of their volumes.
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
166.666667
Explanation for Sample Output 2
The second tetrahedron is completely enclosed by the first tetrahedron, so the answer is the volume 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
523.031980
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
5.995885
Comments