B |
Two
Triangles in 3D Input: Standard Input Output: Standard Output |
There is a red triangle and a blue triangle in 3D space.
When looking from the top (from +z to XY plane), how much red and how much blue would be seen? (Assume you are seeing both the triangles clearly from an infinite distance)
The triangles are opaque so they can block each other.
For example, if the red one is (0,0,0),(3,0,0) and (1,3,0), the blue one is (0,0,1),(3,0,1) and (1,3,1) (See the figure on the left). When looking from the top, both becomes (0,0), (3,0), (1,3), but you can only see the blue one. This figure corresponds to the 3rd sample input.
The first line contains the number of test cases T(1 ≤ T ≤ 3000).
Each test case contains two lines.
Each line contains 9 integers to describe a triangle: x1 y1 z1 x2 y2 z2 x3 y3 z3 (0 ≤ xi, yi, zi ≤ 100). The first line describes the red one, and the second line the blue one. Each triangle is guaranteed to have a strictly positive area. They would never lie on the same plane (As in that case you can't tell which one blocks the other).
Output
For each test case, print two real numbers, the red area and the blue area that can be seen, rounded to 4 decimal places. Absolute errors less than 1.1*10-4 will definitely be ignored.
3 0 0 0 1 0 0 0 1 0 0 0 1 1 0 1 0 1 1 0 0 0 1 0 1 0 1 0 1 0 0 0 0 1 1 1 0 0 0 0 3 0 0 1 3 0 0 0 1 3 0 1 1 3 1 |
0.0000
0.5000 0.3750
0.3750 0.0000
4.5000 |
Problemsetter:
Rujia Liu, Special Thanks: Md. Mahbubul Hasan, Shahriar Manzoor
Explanation
of sample:
In
the first and third case, the red
triangle is completely blocked by the blue one.
In
the second case, two triangles intersect, each is divided into two parts.