TETRA - Sphere in a tetrahedron

no tags 

Of course a Sphere Online Judge System is bound to have some tasks about spheres. So here is one. Given the lengths of the edges of a tetrahedron calculate the radius of a sphere inscribed in that tetrahedron (i.e. a sphere tangent to all the faces).

Input

Number N of test cases in a single line. ( N <= 30 ) Each of the next N lines consists of 6 integer numbers -- the lengths of the edges of a tetrahedron separated by single spaces. The edges are not longer than 1000 and for the tetrahedron WXYZ, the order of the edges is: WX, WY, WZ, XY, XZ, YZ.

Output

N lines, each consisting of a real number given with four digits decimal precision equal to the radius of a sphere inscribed in the given tetrahedron.

Example

Input:
2
1 1 1 1 1 1
1000 999 998 5 5 6

Output:
0.2041
1.4189


hide comments
Alex Anderson: 2012-06-03 21:01:10

@Pathan
You seem to be mistaken.

Metareason: This problem wouldn't exist on spoj for this long if there weren't an answer.

Math reason: Suppose you had a sphere that was tangent to only 3 of the faces. Draw a line from the vertex meeting point of those faces to some central point of the final face. You should be able to move the sphere you have along that line a little bit, and then it won't be tangent to any of the faces, which means it can be larger, which means you didn't have the insphere in the first place.

Last edit: 2012-06-03 21:01:33
Pathan Salman Khan: 2012-02-17 12:02:50

Irregular tetrahedrons don't have one common sphere tangent to all the faces. Please check. You can ask for maximum contained sphere, though.

Peutri: 2010-09-05 13:36:55

There are extra lines past the N test cases.


Added by:Adam Dzedzej
Date:2004-05-11
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS PERL6 VB.NET