Fix unitary tests
[linpy.git] / examples / tesseract.py
1 #!/usr/bin/env python3
2
3 # In geometry, the tesseract is the four-dimensional analog of the cube; the
4 # tesseract is to the cube as the cube is to the square. Just as the surface of
5 # the cube consists of 6 square faces, the hypersurface of the tesseract
6 # consists of 8 cubical cells.
7
8 from linpy import *
9
10
11 x, y, z, t = symbols('x y z t')
12
13 tesseract = Le(0, x, 1) & Le(0, y, 1) & Le(0, z, 1) & Le(0, t, 1)
14
15 def faces(polyhedron):
16 for points in polyhedron.faces():
17 face = points[0].aspolyhedron()
18 face = face.convex_union(*[point.aspolyhedron() for point in points[1:]])
19 yield face
20
21 if __name__ == '__main__':
22 print('Faces of tesseract\n\n {}\n\nare:\n'.format(tesseract))
23 for face in faces(tesseract):
24 assert(len(face.vertices()) == 8)
25 print(' {}'.format(face))