From: Vivien Maisonneuve Date: Wed, 16 Jul 2014 06:38:21 +0000 (+0200) Subject: Improved example diamonds.py X-Git-Tag: 1.0~105 X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/commitdiff_plain/c5ec50e02bb591e2ce3b28131424d21c02255f3b?ds=inline;hp=2a1055d4f4754fa33c53d3f155cc050e4911a2a3 Improved example diamonds.py --- diff --git a/examples/diamond.py b/examples/diamond.py deleted file mode 100755 index 70413e7..0000000 --- a/examples/diamond.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python3 - -import pylab - -from pypol import * - -x, y, z = symbols('x y z') - -# diam = Ge(y, x - 1) & Le(y, x + 1) & Ge(y, -x - 1) & Le(y, -x + 1) -# print('diamond:', diam) -# diam.plot(fill=True, edgecolor='red', facecolor='yellow') -# pylab.show() - -# Chamfered cube -cham = Le(0, x) & Le(x, 3) & Le(0, y) & Le(y, 3) & Le(0, z) & Le(z, 3) & \ - Le(z - 2, x) & Le(x, z + 2) & Le(1 - z, x) & Le(x, 5 - z) & \ - Le(z - 2, y) & Le(y, z + 2) & Le(1 - z, y) & Le(y, 5 - z) & \ - Le(y - 2, x) & Le(x, y + 2) & Le(1 - y, x) & Le(x, 5 - y) -cham_plot = cham.plot(facecolors=(1, 0, 0, 0.75)) -pylab.show() - -# Rhombicuboctahedron -rhom = cham & \ - Le(x + y + z, 7) & Ge(-2, -x - y - z) & \ - Le(-1, x + y - z) & Le(x + y - z, 4) & \ - Le(-1, x - y + z) & Le(x - y + z, 4) & \ - Le(-1, -x + y + z) & Le(-x + y + z, 4) -rhom.plot(facecolors=(0, 1, 0, 0.75)) -pylab.show() - -# Truncated cuboctahedron -cubo = Le(0, x) & Le(x, 5) & Le(0, y) & Le(y, 5) & Le(0, z) & Le(z, 5) & \ - Le(x -4, y) & Le(y, x + 4) & Le(-x + 1, y) & Le(y, -x + 9) & \ - Le(y -4, z) & Le(z, y + 4) & Le(-y + 1, z) & Le(z, -y + 9) & \ - Le(z -4, x) & Le(x, z + 4) & Le(-z + 1, x) & Le(x, -z + 9) & \ - Le(3, x + y + z) & Le(x + y + z, 12) & \ - Le(-2, x - y + z) & Le(x - y + z, 7) & \ - Le(-2, -x + y + z) & Le(-x + y + z, 7) & \ - Le(-2, x + y - z) & Le(x + y - z, 7) -cubo_plot = cubo.plot(facecolors=(0, 0, 1, 0.75)) -pylab.show() diff --git a/examples/diamonds.py b/examples/diamonds.py new file mode 100755 index 0000000..1be9fbb --- /dev/null +++ b/examples/diamonds.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +import matplotlib.pyplot as plt + +from matplotlib import pylab +from mpl_toolkits.mplot3d import Axes3D + +from pypol import * + +x, y, z = symbols('x y z') + +fig = plt.figure() + +diam_plot = fig.add_subplot(2, 2, 1) +diam_plot.set_title('Diamond') +diam_plot.set_xlim(-1, 1) +diam_plot.set_ylim(-1, 1) +diam = Ge(y, x - 1) & Le(y, x + 1) & Ge(y, -x - 1) & Le(y, -x + 1) +diam.plot(diam_plot, fill=True, edgecolor='red', facecolor='yellow') + +cham_plot = fig.add_subplot(2, 2, 2, projection='3d') +cham_plot.set_title('Chamfered cube') +cham_plot.set_xlim(0, 3) +cham_plot.set_ylim(0, 3) +cham_plot.set_zlim(0, 3) +cham = Le(0, x) & Le(x, 3) & Le(0, y) & Le(y, 3) & Le(0, z) & Le(z, 3) & \ + Le(z - 2, x) & Le(x, z + 2) & Le(1 - z, x) & Le(x, 5 - z) & \ + Le(z - 2, y) & Le(y, z + 2) & Le(1 - z, y) & Le(y, 5 - z) & \ + Le(y - 2, x) & Le(x, y + 2) & Le(1 - y, x) & Le(x, 5 - y) +cham.plot(cham_plot, facecolors=(1, 0, 0, 0.75)) + +rhom_plot = fig.add_subplot(2, 2, 3, projection='3d') +rhom_plot.set_title('Rhombicuboctahedron') +rhom_plot.set_xlim(0, 3) +rhom_plot.set_ylim(0, 3) +rhom_plot.set_zlim(0, 3) +rhom = cham & \ + Le(x + y + z, 7) & Ge(-2, -x - y - z) & \ + Le(-1, x + y - z) & Le(x + y - z, 4) & \ + Le(-1, x - y + z) & Le(x - y + z, 4) & \ + Le(-1, -x + y + z) & Le(-x + y + z, 4) +rhom.plot(rhom_plot, facecolors=(0, 1, 0, 0.75)) + +cubo_plot = fig.add_subplot(2, 2, 4, projection='3d') +cubo_plot.set_title('Truncated cuboctahedron') +cubo_plot.set_xlim(0, 5) +cubo_plot.set_ylim(0, 5) +cubo_plot.set_zlim(0, 5) +cubo = Le(0, x) & Le(x, 5) & Le(0, y) & Le(y, 5) & Le(0, z) & Le(z, 5) & \ + Le(x -4, y) & Le(y, x + 4) & Le(-x + 1, y) & Le(y, -x + 9) & \ + Le(y -4, z) & Le(z, y + 4) & Le(-y + 1, z) & Le(z, -y + 9) & \ + Le(z -4, x) & Le(x, z + 4) & Le(-z + 1, x) & Le(x, -z + 9) & \ + Le(3, x + y + z) & Le(x + y + z, 12) & \ + Le(-2, x - y + z) & Le(x - y + z, 7) & \ + Le(-2, -x + y + z) & Le(-x + y + z, 7) & \ + Le(-2, x + y - z) & Le(x + y - z, 7) +cubo.plot(cubo_plot, facecolors=(0, 0, 1, 0.75)) +pylab.show()