From: Vivien Maisonneuve <v.maisonneuve@gmail.com>
Date: Sun, 13 Jul 2014 14:07:45 +0000 (+0200)
Subject: Add tesseract example
X-Git-Tag: 1.0~111
X-Git-Url: https://scm.cri.minesparis.psl.eu/git/linpy.git/commitdiff_plain/7c6b2612e47086563cd58ae57c13a7a1beca03b8?ds=sidebyside

Add tesseract example
---

diff --git a/examples/tesseract.py b/examples/tesseract.py
new file mode 100755
index 0000000..b2a5e97
--- /dev/null
+++ b/examples/tesseract.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+from pypol import *
+
+x, y, z, t = symbols('x y z t')
+
+tesseract = \
+    Le(0, x) & Le(x, 1) & \
+    Le(0, y) & Le(y, 1) & \
+    Le(0, z) & Le(z, 1) & \
+    Le(0, t) & Le(t, 1)
+
+def faces(polyhedron):
+    for points in polyhedron.faces():
+        face = points[0].aspolyhedron()
+        face = face.union(*[point.aspolyhedron() for point in points[1:]])
+        face = face.aspolyhedron()
+        yield face
+
+print('Faces of tesseract\n\n  {}\n\nare:\n'.format(tesseract))
+for face in faces(tesseract):
+    assert(len(face.vertices()) == 8)
+    print('  {}'.format(face))