More fun with plots
[linpy.git] / examples / diamond.py
index e82581e..70413e7 100755 (executable)
@@ -1,18 +1,41 @@
 #!/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)
-print() 
-rhom1 = Le(0, x) & Le(x, 3) & Le(0, y) & Le(y, 3) & Le(0, z) & Le(z, 3) \
-& Le(z - 2, x) & Ge(z + 2, x) & Ge(z - 1, -x) & Le(z - 5, -x) \
-& Le(z - 2, y) & Ge(z + 2, y) & Ge(z - 1, -y) & Le(z - 5, -y) \
-& Le(y - 2, x) & Ge(y + 2, x) & Ge(y - 1, -x) & Le(y - 5, -x)
-rhom1.plot()
-rhom2 = rhom1 & Le(x + y + z, 7) & Ge(-2, -x - y - z ) \
-& Le(x + y - z, 4) & Ge(x + y - z, -1) \
-& Le(x - y + z, 4) & Ge(x - y + z, -1) \
-& Le(-x + y + z, 4) & Ge(-x + y + z, -1)
-rhom2.plot()
+
+# 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()