| 1 | initial version |
The following code gets the (3D) vertices as list, starting from a special polyhedron:
[ v.vector().list() for v in t.vertices() ]
For this, let us compare...
sage: t = polytopes.tetrahedron()
sage: t.vertices()
(A vertex at (0, 0, 0),
A vertex at (0, 1, 1),
A vertex at (1, 0, 1),
A vertex at (1, 1, 0))
sage: [ v.vector() for v in t.vertices() ]
[(0, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0)]
sage: [ v.vector().list() for v in t.vertices() ]
[[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0]]
sage: v = t.vertices()[0]
sage: print "v has type", type(v)
v has type <class 'sage.geometry.polyhedron.representation.Vertex'>
sage: print "v.vector() has type", type( v.vector() )
v.vector() has type <type 'sage.modules.vector_integer_dense.Vector_integer_dense'>
sage: print "v.vector().list() has type", type( v.vector().list() )
v.vector().list() has type <type 'list'>
It is always useful to look at one element, a vertex, instantiated as a variable v above, then to inspect its methods. Very often, the name will already be enough to guess the right needed method. Note that the vector representation of the vertices may also be enough.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.