In [1]:
P1 = Polyhedron(vertices = [[1, 0], [0, 1]], rays = [[1, 1]])
In [2]:
P1
Out[2]:
The string representation already gives a lot of information:
Of course, you want to know what this object looks like:
In [3]:
P1.plot()
Out[3]:
We can also add a lineality space.
We can see all the methods available by pressing
In [4]:
P1.
In [5]:
P2 = Polyhedron(vertices = [[1/2, 0, 0], [0, 1/2, 0]],rays = [[1, 1, 0]],lines = [[0, 0, 1]])
In [6]:
P2
Out[6]:
In [7]:
P1.parent()
Out[7]:
In [8]:
P2.parent()
Out[8]:
In [9]:
for h in P1.Hrepresentation():
print(h)
Each line gives a row of the matrix $A$ and an entry of the vector $b$. The variable $x$ is a vector in the ambient space where $P1$ is defined. The $H$-representation may contain equations:
The construction of a polyhedron object via its $H$-representation, requires a precise format. Each inequality $(a_{i1},\ldots,a_{id})⋅x+bi\geq 0$ must be written as $[b_i,a_{i1}, \ldots, a_{id}]$.
It is worth using the parameter eqns to shorten the construction of the object. In the following example, the first four rows are the negative of the second group of four rows.
As we learned from lectures, examples are very important. Sage has implemented several examples: http://doc.sagemath.org/html/en/reference/discrete_geometry/sage/geometry/polyhedron/library.html"
In [20]:
P3_QQ = Polyhedron(vertices = [[0.5, 0], [0, 0.5]], base_ring=QQ)
In [21]:
HRep = P3_QQ.Hrepresentation()
In [22]:
H1 = HRep[0]; H1
Out[22]:
In [23]:
H2 = HRep[1]; H2
Out[23]:
In [24]:
H1.A()
Out[24]:
In [25]:
H1.b()
Out[25]:
In [26]:
H1.is_equation()
Out[26]:
In [27]:
H1.is_inequality()
Out[27]:
In [28]:
H1.contains(vector([0,0]))
Out[28]:
In [29]:
H2.contains(vector([0,0]))
Out[29]:
In [30]:
H1.is_incident(H2)
Out[30]:
It is possible to obtain the different objects of the H-representation as follows.
In [31]:
P3_QQ.equations()
Out[31]:
In [32]:
P3_QQ.inequalities()
Out[32]:
In [33]:
VRep = P2.Vrepresentation(); VRep
Out[33]:
In [34]:
L = VRep[0]; L
Out[34]:
In [35]:
V = VRep[1]; V
Out[35]:
In [36]:
R = VRep[3]; R
Out[36]:
In [37]:
L.is_line()
Out[37]:
In [38]:
L.is_incident(V)
Out[38]:
In [39]:
R.is_incident(L)
Out[39]:
In [40]:
L.vector()
Out[40]:
In [41]:
V.vector()
Out[41]:
It is possible to obtain the different objects of the V-representation as follows.
In [42]:
P2.vertices()
Out[42]:
In [43]:
P2.rays()
Out[43]:
In [44]:
P2.lines()
Out[44]:
In [45]:
P2.vertices_matrix()
Out[45]:
In [ ]:
In [ ]:
Exercise A
In this exercise, you will construct the cuboctahedron in several different ways and verify that you get the same combinatorial type.
1) The first options is to check if it is in the library: http://doc.sagemath.org/html/en/reference/discrete_geometry/sage/geometry/polyhedron/library.html. It is! So we can just use the provided construction.
In [46]:
CO = polytopes.cuboctahedron()
Let's see if it looks like what we expect:
In [47]:
CO.plot()
Out[47]:
We can ask the $f$-vector of the cuboctahedron:
In [48]:
CO.f_vector()
Out[48]:
2) The second construction uses the fact that we can truncate the vertices by new hyperplanes that cross the edges exactly at the mid-point.
In [49]:
Cube = polytopes.cube()
In [53]:
EC = Cube.edge_truncation(1/2)
Just to make a sanity check we can compute the f-vector:
In [54]:
EC.f_vector()
Out[54]:
But as we know, two different polytopes can have the same f-vector, so we should check if they are combinatorially isomorphic:
In [55]:
EC.is_combinatorially_isomorphic(CO)
Out[55]:
This is great!
Just to understand the truncation construction better, visualize the usual truncation:
In [56]:
TC = Cube.truncation()
In [57]:
TC.show()
3) The third construction will use some nice trick that we can do in sage.
We can take the polar dual of the cube, the octahedron, and scale it by a factor 2:
In [58]:
OC = 2*Cube.polar()
Then, we can take the intersection with the cube again :
In [59]:
ECCO = Cube & OC
What is ECCO?
In [60]:
ECCO.is_combinatorially_isomorphic(EC)
Out[60]:
That's it! You found 3 ways to construct the cuboctahedron.
Exercise B
Choose five examples discussed in lecture from the list: http://doc.sagemath.org/html/en/reference/discrete_geometry/sage/geometry/polyhedron/library.html" And find their $V$-representation, $H$-representation, and $f$-vector
In [ ]:
In [ ]: