UTS Open '15 #6 - Tetrahedra (Volume)

View as PDF

Submit solution

Points: 25 (partial)
Time limit: 0.6s
Memory limit: 64M

Authors:
Problem type

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:

Picture of the ROM

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 [0,1000]. 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 10^{-6}.

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 a_1 be a vertex of a tetrahedron and let b_1,b_2,b_3 be vertices of the other tetrahedron. It is guaranteed that a_1 does not lie on the plane formed by b_1,b_2,b_3.
  • Let a_1,a_2 be vertices of a tetrahedron and let b_1,b_2 be vertices of the other tetrahedron. It is guaranteed that the line passing through a_1 and a_2 does not intersect the line passing through b_1 and b_2.

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

3D model of 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

Picture for Sample Input 4

3D model of Sample Input 4


Comments

There are no comments at the moment.