According to a proof by Dr. Robert Gray, at one time archived on a Synergetics listserv, any tetrahedron of IVM vertexes (assuming non-coplanar) will have a whole number volume.
In this Notebook, we randomly generate IVM tetrahedrons and compute their volumes. Within the error of floating point, we demonstrate this result.
In [1]:
from tetravolume import Qvector
In [2]:
import gmpy2
from gmpy2 import mpfr
gmpy2.get_context().precision=200
mpfr(0)
Out[2]:
In [3]:
from itertools import permutations
In [4]:
combos = set()
for combo in permutations((0,1,1,2)):
combos.add(combo)
combos = list(combos)
combos
Out[4]:
One frequency:
In [5]:
import random
def any_ball():
# random coefficients for arbitrary choice of vectors...
coeffs = [random.randint(0, 300) for _ in range(12)]
vectors = ([coeffs[i] * Qvector(combos[i]) for i in range(12)])
vector_sum = Qvector((mpfr(0),mpfr(0),mpfr(0),mpfr(0)))
for v in vectors:
vector_sum = vector_sum + v
return vector_sum
any_ball()
Out[5]:
In [6]:
A,B,C,D = any_ball(), any_ball(), any_ball(), any_ball()
A
Out[6]:
In [7]:
A-B
Out[7]:
In [8]:
(A-B).length()
Out[8]:
In [9]:
lengths = [("AB", (A-B).length()),
("AC", (A-C).length()),
("AD", (A-D).length()),
("BC", (B-C).length()),
("CD", (C-D).length()),
("DB", (D-B).length())]
In [10]:
lengths
Out[10]:
In [11]:
from tetravolume import Tetrahedron
In [12]:
t = Tetrahedron(*[lengths[i][1] for i in range(6)])
In [13]:
t.ivm_volume()
Out[13]:
In [14]:
def demo():
A,B,C,D = any_ball(), any_ball(), any_ball(), any_ball()
lengths = [("AB", (A-B).length()),
("AC", (A-C).length()),
("AD", (A-D).length()),
("BC", (B-C).length()),
("CD", (C-D).length()),
("DB", (D-B).length())]
t = Tetrahedron(*[lengths[i][1] for i in range(6)])
return t.ivm_volume()
demo()
Out[14]:
In [15]:
t.xyz_volume()
Out[15]:
In [16]:
from IPython.display import YouTubeVideo
YouTubeVideo("wLHescQT2ZI") # https://youtu.be/wLHescQT2ZI
Out[16]: