Program to find the area of all faces in irregular tetrahedron, radius of inscribed sphere and Volume of the Tetrahedron.

The all side of an irregular tetrahedron given. The task is to determine the area of its all faces and find radius of inscribed sphere and also find its volume. Let the side is d12, d13, d14, d23, d24,d34 .


Irregular Tetrahedron Source:Google





3D view of Sphere

When we have all side distance given. we use this formula which is given by Cayley–Menger_determinant.

                      Cayley-Menger Determinant

To find the volume of irregular tetrahedron use Below formula:
Volume^2 = sqrt(V/288) 
V=sqrt(4*d12*d12*d13*d13*d14 – d12*(d13*d13 + d14*d14 – d34*d34)^2 – d13*d13(d14*d14 + d12*d12 – d24*d24)^2 – d13*d13(d12*d12 + d13*vd13– d23*d23)^2 + (d12*d12+ d13*d13 – d23*d23) * (d14*d14 + d12*d12 – d24*d24) * (d13*d13 + d14*d14 – d34*d34)) / 12

Formula for volume Is given above. for finding Area of faces use Formula:

S1=d1+d2+d4/2

Area1 =sqrt(S*(S-d1)*(S-d2)*(S-d4))

Total Area Of Faces=(A1+A2+A3+A4)

Radius Of Sphere=3*Volume/(Total Area Of Faces)

Input/Output: 

Input: d12 = 6, d13 = 7, d14 = 8, d34 = 9, d24 = 10, d23 = 11
Output:
Volume Of Tetrahedron: 48.00000000000002
Area Of Faces D123 Side: 18.973665961010276
Area Of Faces D134 Side: 26.832815729997478
Area Of Faces D124 Side: 24.0
Area Of Faces D234 Side: 42.42640687119285
Inscribe Circle Radius 1.1327163668123923

INPUT:d12 = 11,d13 = 10,d14 = 9,d34 = 8,d24 = 7,d23 = 6

Output:

Volume Of Tetrahedron: 56.67836888972724
Area Of Faces D123 Side: 29.764702249476645
Area Of Faces D134 Side: 34.197039345533994
Area Of Faces D124 Side: 31.419540098480116
Area Of Faces D234 Side: 20.33316256758894
Inscribe Circle Radius 1.2122034400532904

 

Below is the implementation of the above approach:  Python Programming Used:
# Python program for finding the radius of inscribed sphere in irregular Tetrahedron.
import math
import numpy as upendra
def radius(d12,d13,d14,d34,d24,d23):

   arr = upendra.array([[0, d12**2, d13**2, d14**2, 1], [d12**2, 0, d23**2, d24**2, 1],
                     [d13**2, d23**2, 0, d34**2, 1], [d14**2, d24**2, d34**2, 0, 1], [1, 1, 1, 1, 0]])
   Det = upendra.linalg.det(arr)
   Vol = math.sqrt(Det/288)  # For Python 2.7.5 Use math.sqrt(float(Det)/288)
   print("Volume Of Tetrahedron:", Vol)
   s1 = (d12+d23+d13)/2
   a1 = math.sqrt(s1*(s1-d12)*(s1-d23)*(s1-d13))  # Area Of Faces These Side.
   print("Area Of Faces D123 Side:", a1)

   s2 = (d14+d34+d13)/2
   a2 = math.sqrt(s2*(s2-d14)*(s2-d34)*(s2-d13))  # Area Of Faces These Side.
   print("Area Of Faces D134 Side:", a2)
   s3 = (d12+d24+d14)/2
   a3 = math.sqrt(s1*(s1-d12)*(s1-d24)*(s1-d14))  # Area Of Faces These Side.
   print("Area Of Faces D124 Side:", a3)
   s4 = (d23+d24+d34)/2
   a4 = math.sqrt(s4*(s4-d23)*(s4-d24)*(s4-d34))  # Area Of Faces These Side.
   print("Area Of Faces D234 Side:", a4)

   # To Round answere Use Round Function EX. round(a1,4) it's print only four decimal
   print("Ins Cribe Circle Radius", math.sqrt(3*Vol/(a1+a2+a3+a4)))
   
if __name__ == "__main__" :
  d12 = 6 
  d13 = 7
  d14 = 8
  d34 = 9
  d24 = 10
  d23 = 11
  radius(d12,d13,d14,d34,d24,d23)
# This code is contributed by Upendra Charasiya

Output:

Volume Of Tetrahedron: 48.00000000000002
Area Of Faces D123 Side: 18.973665961010276
Area Of Faces D134 Side: 26.832815729997478
Area Of Faces D124 Side: 24.0
Area Of Faces D234 Side: 42.42640687119285
Inscribe Circle Radius 1.1327163668123923

 

Time Complexity: O(n) as using inbuilt numpy function.

Auxiliary Space: O(1) 

                                   Thank You So Much For Giving Your Valuable Time 

#Practice_Makes_Coding_Perfect

Comments

Popular posts from this blog

GeeksforGeeks 2 October Problem: Enemy

Computer game, This is the Problem statement given in the techgig Platform.