Back to Blog

Geometric Compactness Ratio of Tetrahedrons: A Computational Study Based on Edge Lengths

By Toriqul Haque·
Geometric Compactness Ratio of Tetrahedrons: A Computational Study Based on Edge Lengths
Tetrahedron Geometry Explanation & Research

Tetrahedron Geometry: C++ Code, Explanation and Research Idea

Original C++ Code

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
   int t;
   cin >> t;
   while (t--) {
       double a, b, c, d, e, f;
       cin >> a >> b >> c >> d >> e >> f;

       double det = 4*a*a*b*b*c*c - a*a*(b*b + c*c - f*f)*(b*b + c*c - f*f) -
                    b*b*(a*a + c*c - e*e)*(a*a + c*c - e*e) -
                    c*c*(a*a + b*b - d*d)*(a*a + b*b - d*d) +
                    (b*b + c*c - f*f)*(a*a + c*c - e*e)*(a*a + b*b - d*d);
       double v = sqrt(det) / 12;

       double s1 = (a + b + d) / 2;
       double area1 = sqrt(s1 * (s1 - a) * (s1 - b) * (s1 - d));

       double s2 = (a + c + e) / 2;
       double area2 = sqrt(s2 * (s2 - a) * (s2 - c) * (s2 - e));

       double s3 = (b + c + f) / 2;
       double area3 = sqrt(s3 * (s3 - b) * (s3 - c) * (s3 - f));

       double s4 = (d + e + f) / 2;
       double area4 = sqrt(s4 * (s4 - d) * (s4 - e) * (s4 - f));

       double s = area1 + area2 + area3 + area4;
       cout << fixed << setprecision(4) << 3 * v / s << endl;
   }
   return 0;
}
    

Explanation of the Code

This code is designed to calculate a geometric property based on the lengths of the edges of a tetrahedron (a 3D shape with 4 triangular faces).

Input/Output

  • t = number of test cases
  • Each test case provides 6 values: edge lengths
  • a, b, c = edges from a common point (vertex A to B, C, D)
  • d, e, f = other edges to form the tetrahedron
  • Output: a value computed as 3 × Volume / Surface Area to 4 decimal places

Step-by-Step Breakdown

1. Reading Input

cin >> a >> b >> c >> d >> e >> f;

These represent the lengths of the 6 edges of a tetrahedron.

2. Calculating Volume

The Cayley-Menger determinant is used to calculate the volume of the tetrahedron:

double det = ...; double v = sqrt(det) / 12;

3. Calculating Surface Area

Each face of the tetrahedron is a triangle. The area is computed using Heron’s formula:

double s1 = (a + b + d) / 2; double area1 = sqrt(s1 * (s1 - a) * (s1 - b) * (s1 - d));

Repeat for the other faces to get area2, area3, and area4.

4. Final Output

cout << fixed << setprecision(4) << 3 * v / s << endl;

This outputs the compactness ratio: 3 × Volume / Surface Area, a dimensionless measure of the tetrahedron's geometry.

Research Idea from the Code

Title:

Geometric Compactness Ratio of Tetrahedrons: A Computational Study Based on Edge Lengths

Objective:

To investigate how the compactness ratio behaves across a wide range of randomly generated tetrahedrons with different edge configurations.

Research Questions:

  • What are the maximum and minimum values of 3V/S for a valid tetrahedron?
  • How do different edge distributions (uniform, normal, skewed) affect this ratio?
  • Can this ratio help classify tetrahedrons (regular, flat, spiky)?
  • Can it be applied in molecular modeling, mesh optimization, or 3D-printing geometry validation?

Methodology:

  • Generate large sets of valid edge lengths forming tetrahedrons
  • Use the Cayley-Menger determinant to validate geometry
  • Calculate:
    • Volume via Cayley-Menger
    • Surface area via Heron’s formula
    • Compactness ratio 3V/S
  • Visualize trends using tools like Matplotlib or Seaborn

Applications:

  • Material Science: analyzing clusters or particles
  • Machine Learning: feature extraction from 3D datasets
  • Geology & Biology: studying natural or organic structures
  • Computer Graphics: mesh simplification and shape optimization