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
An integer t, 1<=t<=30, denoting the number of test cases, followed by t lines, each containing 6 integers describing 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
t 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
Refer this blog for formula : http://saketsaurabh.in/blog/2009/11/radius-of-a-sphere-inscribed-in-a-general-tetrahedron/
Input
An integer t, 1<=t<=30, denoting the number of test cases, followed by t lines, each containing 6 integers describing 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
t 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
Refer this blog for formula : http://saketsaurabh.in/blog/2009/11/radius-of-a-sphere-inscribed-in-a-general-tetrahedron/
#include<stdio.h>
#include<math.h>
double area(double p,double q,double r)
{
double s=0,area1;
s=(p+q+r)/2;
area1=sqrt(s*(s-p)*(s-q)*(s-r));
return area1;
}
int main()
{
double a,b,c,d,e,f,x,y,A,B,C,D,E,F;
int t;
double v,s,r;
scanf("%d",&t);
while(t--)
{
s=0;
scanf("%lf%lf%lf%lf%lf%lf",&F,&B,&D,&C,&E,&A);
a=A*A;
b=B*B;
c=C*C;
d=D*D;
e=E*E;
f=F*F;
x=(a*c*d)+(b*c*d)+(a*b*e)+(b*c*e)+(b*d*e)+(c*d*e)+(a*b*f)+(a*c*f)+(a*d*f)+(c*d*f)+(a*e*f)+(b*e*f);
y=(a*b*d)+(a*c*e)+(b*c*f)+(d*e*f)+(c*c*d)+(c*d*d)+(b*b*e)+(b*e*e)+(a*a*f)+(a*f*f);
v=sqrt(x-y)/12;
s=area(B,C,F)+area(D,E,F)+area(B,A,D)+area(A,E,C);
r=(v*3)/s;
printf("%.4lf\n",r);
}
return 0;
}