70413e7cf18e56119f1d336bbef0a6aef177a806
[linpy.git] / examples / diamond.py
1 #!/usr/bin/env python3
2
3 import pylab
4
5 from pypol import *
6
7 x, y, z = symbols('x y z')
8
9 # diam = Ge(y, x - 1) & Le(y, x + 1) & Ge(y, -x - 1) & Le(y, -x + 1)
10 # print('diamond:', diam)
11 # diam.plot(fill=True, edgecolor='red', facecolor='yellow')
12 # pylab.show()
13
14 # Chamfered cube
15 cham = Le(0, x) & Le(x, 3) & Le(0, y) & Le(y, 3) & Le(0, z) & Le(z, 3) & \
16 Le(z - 2, x) & Le(x, z + 2) & Le(1 - z, x) & Le(x, 5 - z) & \
17 Le(z - 2, y) & Le(y, z + 2) & Le(1 - z, y) & Le(y, 5 - z) & \
18 Le(y - 2, x) & Le(x, y + 2) & Le(1 - y, x) & Le(x, 5 - y)
19 cham_plot = cham.plot(facecolors=(1, 0, 0, 0.75))
20 pylab.show()
21
22 # Rhombicuboctahedron
23 rhom = cham & \
24 Le(x + y + z, 7) & Ge(-2, -x - y - z) & \
25 Le(-1, x + y - z) & Le(x + y - z, 4) & \
26 Le(-1, x - y + z) & Le(x - y + z, 4) & \
27 Le(-1, -x + y + z) & Le(-x + y + z, 4)
28 rhom.plot(facecolors=(0, 1, 0, 0.75))
29 pylab.show()
30
31 # Truncated cuboctahedron
32 cubo = Le(0, x) & Le(x, 5) & Le(0, y) & Le(y, 5) & Le(0, z) & Le(z, 5) & \
33 Le(x -4, y) & Le(y, x + 4) & Le(-x + 1, y) & Le(y, -x + 9) & \
34 Le(y -4, z) & Le(z, y + 4) & Le(-y + 1, z) & Le(z, -y + 9) & \
35 Le(z -4, x) & Le(x, z + 4) & Le(-z + 1, x) & Le(x, -z + 9) & \
36 Le(3, x + y + z) & Le(x + y + z, 12) & \
37 Le(-2, x - y + z) & Le(x - y + z, 7) & \
38 Le(-2, -x + y + z) & Le(-x + y + z, 7) & \
39 Le(-2, x + y - z) & Le(x + y - z, 7)
40 cubo_plot = cubo.plot(facecolors=(0, 0, 1, 0.75))
41 pylab.show()