X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/51e97eade63b2f4c7b500feb503436cc4a886e59..d585b06ccf67b2837519f4b48c6800dcdb924d9d:/examples/tesseract.py?ds=sidebyside diff --git a/examples/tesseract.py b/examples/tesseract.py index eaccf43..d692e37 100755 --- a/examples/tesseract.py +++ b/examples/tesseract.py @@ -1,42 +1,28 @@ #!/usr/bin/env python3 -""" - This file is part of Linpy. +# In geometry, the tesseract is the four-dimensional analog of the cube; the +# tesseract is to the cube as the cube is to the square. Just as the surface of +# the cube consists of 6 square faces, the hypersurface of the tesseract +# consists of 8 cubical cells. - Linpy is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. +from linpy import Le, symbols - Linpy is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Linpy. If not, see . -""" - -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) +tesseract = Le(0, x, 1) & Le(0, y, 1) & Le(0, z, 1) & Le(0, 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() + face = face.convex_union(*[point.aspolyhedron() + for point in points[1:]]) 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)) - -# Copyright 2014 MINES ParisTech + +if __name__ == '__main__': + print('Faces of tesseract\n\n {}\n\nare:\n'.format(tesseract)) + for face in faces(tesseract): + assert(len(face.vertices()) == 8) + print(' {}'.format(face))