Plot domain added
[linpy.git] / examples / diamonds.py
1 #!/usr/bin/env python3
2
3 import matplotlib.pyplot as plt
4
5 from matplotlib import pylab
6 from mpl_toolkits.mplot3d import Axes3D
7
8 from pypol import *
9
10 x, y, z = symbols('x y z')
11
12 fig = plt.figure(facecolor='white')
13
14 diam_plot = fig.add_subplot(2, 2, 1, aspect='equal')
15 diam_plot.set_title('Diamond')
16 diam = Ge(y, x - 1) & Le(y, x + 1) & Ge(y, -x - 1) & Le(y, -x + 1)
17 diam.plot(diam_plot, fill=True, edgecolor='red', facecolor='yellow')
18
19 cham_plot = fig.add_subplot(2, 2, 2, projection='3d', aspect='equal')
20 cham_plot.set_title('Chamfered cube')
21 cham = Le(0, x) & Le(x, 3) & Le(0, y) & Le(y, 3) & Le(0, z) & Le(z, 3) & \
22 Le(z - 2, x) & Le(x, z + 2) & Le(1 - z, x) & Le(x, 5 - z) & \
23 Le(z - 2, y) & Le(y, z + 2) & Le(1 - z, y) & Le(y, 5 - z) & \
24 Le(y - 2, x) & Le(x, y + 2) & Le(1 - y, x) & Le(x, 5 - y)
25 cham.plot(cham_plot, facecolors=(1, 0, 0, 0.75))
26
27 rhom_plot = fig.add_subplot(2, 2, 3, projection='3d', aspect='equal')
28 rhom_plot.set_title('Rhombicuboctahedron')
29 rhom = cham & \
30 Le(x + y + z, 7) & Ge(-2, -x - y - z) & \
31 Le(-1, x + y - z) & Le(x + y - z, 4) & \
32 Le(-1, x - y + z) & Le(x - y + z, 4) & \
33 Le(-1, -x + y + z) & Le(-x + y + z, 4)
34 rhom.plot(rhom_plot, facecolors=(0, 1, 0, 0.75))
35
36 cubo_plot = fig.add_subplot(2, 2, 4, projection='3d', aspect='equal')
37 cubo_plot.set_title('Truncated cuboctahedron')
38 cubo = Le(0, x) & Le(x, 5) & Le(0, y) & Le(y, 5) & Le(0, z) & Le(z, 5) & \
39 Le(x -4, y) & Le(y, x + 4) & Le(-x + 1, y) & Le(y, -x + 9) & \
40 Le(y -4, z) & Le(z, y + 4) & Le(-y + 1, z) & Le(z, -y + 9) & \
41 Le(z -4, x) & Le(x, z + 4) & Le(-z + 1, x) & Le(x, -z + 9) & \
42 Le(3, x + y + z) & Le(x + y + z, 12) & \
43 Le(-2, x - y + z) & Le(x - y + z, 7) & \
44 Le(-2, -x + y + z) & Le(-x + y + z, 7) & \
45 Le(-2, x + y - z) & Le(x + y - z, 7)
46 cubo.plot(cubo_plot, facecolors=(0, 0, 1, 0.75))
47 pylab.show()