Package sage :: Package geometry :: Module polyhedra :: Class Polyhedron
[hide private]
[frames] | no frames]

Class Polyhedron

source code

                      object --+    
                               |    
structure.sage_object.SageObject --+
                                   |
                                  Polyhedron

Instance Methods [hide private]
 
__init__(self, vertices=[], rays=[], ieqs=[], linearities=[])
A class for polyhedral objects.
source code
 
_repr_(self)
Returns a description of the object.
source code
 
dim(self)
Returns the dimension of the polyhedron.
source code
 
is_simple(self)
Tests for simplicity of a polytope.
source code
 
__add__(self, other)
Addition of two polyhedra is defined as their Minkowski sum.
source code
 
vertices(self, force_from_ieqs=False)
Returns the vertices of the polyhedron.
source code
 
ieqs(self, force_from_vertices=False)
Return the inequalities (half-planes) defining the polyhedron.
source code
 
vertex_adjacencies(self)
Returns a list of vertex indices and their adjacent vertices.
source code
 
facial_adjacencies(self)
Returns a list of face indices and the indices of faces adjacent to them.
source code
 
linearities(self)
Returns the linear constraints of the polyhedron.
source code
 
remove_redundant_vertices(self)
Removes vertices from the description of the polyhedron which do not affect the convex hull.
source code
 
rays(self)
Returns the rays.
source code
 
facial_incidences(self)
Returns the face-vertex incidences in the form [face_index, [v_i_0, v_i_1,,v_i_2]]...
source code
 
triangulated_facial_incidences(self)
WARNING: EXPERIMENTAL Returns a list of the form [face_index, [v_i_0, v_i_1,,v_i_2]] where the face_index refers to the original defining inequality.
source code
 
render_wireframe(self)
For polytopes in 2 or 3 dimensions, returns the edges as a list of lines.
source code

Inherited from structure.sage_object.SageObject: __hash__, __new__, __repr__, _axiom_, _axiom_init_, _gap_, _gap_init_, _gp_, _gp_init_, _interface_, _interface_init_, _interface_is_cached_, _kash_, _kash_init_, _macaulay2_, _macaulay2_init_, _magma_, _magma_init_, _maple_, _maple_init_, _mathematica_, _mathematica_init_, _maxima_, _maxima_init_, _octave_, _octave_init_, _pari_, _pari_init_, _r_init_, _sage_, _singular_, _singular_init_, category, db, dump, dumps, plot, rename, reset_name, save, version

Inherited from object: __delattr__, __getattribute__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, vertices=[], rays=[], ieqs=[], linearities=[])
(Constructor)

source code 

A class for polyhedral objects.  Architecture is still in flux.
Do not instantiate with both vertex/ray and ieq/linearity data:
no consistency check is made.

EXAMPLES:
    sage: square_from_vertices = Polyhedron(vertices = [[1, 1], [1, -1], [-1, 1], [-1, -1]])
    sage: square_from_ieqs = Polyhedron(ieqs = [[1, 0, 1], [1, 1, 0], [1, 0, -1], [1, -1, 0]])
    sage: square_from_ieqs.vertices()
    [[1, -1], [1, 1], [-1, 1], [-1, -1]]
    sage: square_from_vertices.ieqs()
    [[1, 0, 1], [1, 1, 0], [1, 0, -1], [1, -1, 0]]

Overrides: object.__init__

_repr_(self)

source code 

Returns a description of the object.

EXAMPLES:
    sage: poly_test = Polyhedron(vertices = [[1,2,3,4],[2,1,3,4],[4,3,2,1]])
    sage: poly_test._repr_()
    'A Polyhedron with 3 vertices.'
    sage: grammar_test = Polyhedron(vertices = [[1,1,1,1,1,1]])
    sage: grammar_test._repr_()
    'A Polyhedron with 1 vertex.'

dim(self)

source code 

Returns the dimension of the polyhedron.

EXAMPLES:
    sage: standard_simplex = Polyhedron(vertices = [[1,0,0,0],[0,0,0,1],[0,1,0,0],[0,0,1,0]])
    sage: standard_simplex.dim()
    3

is_simple(self)

source code 

Tests for simplicity of a polytope.

EXAMPLES:
    sage: p = Polyhedron([[0,0,0],[1,0,0],[0,1,0],[0,0,1]])
    sage: p.remove_redundant_vertices()
    sage: p.is_simple()
    True
    sage: p = Polyhedron([[0,0,0],[4,4,0],[4,0,0],[0,4,0],[2,2,2]])
    sage: p.is_simple()
    False

__add__(self, other)
(Addition operator)

source code 

Addition of two polyhedra is defined as their Minkowski sum.

EXAMPLES:
    sage: four_cube = n_cube(4)
    sage: four_simplex = Polyhedron(vertices = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]])
    sage: unholy_union = four_cube + four_simplex
    sage: unholy_union.dim()
    4

vertices(self, force_from_ieqs=False)

source code 

Returns the vertices of the polyhedron.

EXAMPLES:
    sage: a_simplex = Polyhedron(ieqs = [[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0],[0,0,0,0,1]], linearities = [[1,-1,-1,-1,-1]])
    sage: a_simplex.vertices()
    [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]]

ieqs(self, force_from_vertices=False)

source code 

Return the inequalities (half-planes) defining the polyhedron.

EXAMPLES:
    sage: permuto4 = Polyhedron(vertices = permutations([1,2,3,4,5]))
    sage: ieqs = permuto4.ieqs()
    sage: ieqs[0]
    [-1, 0, 0, 0, 1, 0]
    sage: ieqs[-1]
    [5, -1, 0, 0, 0, 0]

vertex_adjacencies(self)

source code 

Returns a list of vertex indices and their adjacent vertices.

EXAMPLES:
    sage: permuto3 = Polyhedron(vertices = permutations([1,2,3,4]))
    sage: permuto3.vertex_adjacencies()[0:3]
    [[3, [5, 1, 9]], [5, [3, 4, 11]], [16, [22, 10, 17]]]

facial_adjacencies(self)

source code 

Returns a list of face indices and the indices of faces adjacent to them.

EXMAPLES:
    sage: permuto3 = Polyhedron(vertices = permutations([1,2,3,4]))
    sage: permuto3.facial_adjacencies()[0:3]
    [[0, [1, 2, 3, 8, 12, 13, 14]],
    [1, [0, 2, 9, 13, 14]],
    [2, [0, 1, 3, 4, 5, 9, 14]]]

linearities(self)

source code 

Returns the linear constraints of the polyhedron. As with
inequalities, each constraint is given as [b -a1 -a2 ... an]
where for variables x1, x2,..., xn, the polyhedron satisfies
the equation b = a1*x1 + a2*x2 + ... + an*xn.

EXAMPLES:
    sage: test_p = Polyhedron(vertices = [[1,2,3,4],[2,1,3,4],[4,3,2,1],[3,4,1,2]])
    sage: test_p.linearities()
    [[-10, 1, 1, 1, 1]]

remove_redundant_vertices(self)

source code 

Removes vertices from the description of the polyhedron which
do not affect the convex hull.  Now done automatically when a
polyhedron is defined by vertices.

EXAMPLES:
    sage: a_triangle = Polyhedron([[0,0,0],[4,0,0],[0,4,0],[1,1,0]])
    sage: a_triangle.vertices()
    [[0, 0, 0], [4, 0, 0], [0, 4, 0]]
    sage: a_triangle.remove_redundant_vertices()
    sage: a_triangle.vertices()
    [[0, 0, 0], [4, 0, 0], [0, 4, 0]]

rays(self)

source code 

Returns the rays.  This function does not ensure that redundant
rays have been removed.

EXAMPLES:
    sage: positive_orthant = Polyhedron(ieqs = [[0,1,0,0],[0,0,1,0],[0,0,0,1]])
    sage: positive_orthant.rays()
    [[1, 0, 0], [0, 1, 0], [0, 0, 1]]

facial_incidences(self)

source code 

Returns the face-vertex incidences in the form [face_index, [v_i_0, v_i_1,,v_i_2]]

EXAMPLES:
    sage: p = Polyhedron(vertices = [[5,0,0],[0,5,0],[5,5,0],[0,0,0],[2,2,5]])
    sage: p.facial_incidences()
    [[0, [1, 3, 4]],
    [1, [0, 3, 4]],
    [2, [0, 2, 4]],
    [3, [1, 2, 4]],
    [4, [0, 1, 2, 3]]]

triangulated_facial_incidences(self)

source code 

WARNING: EXPERIMENTAL
Returns a list of the form [face_index, [v_i_0, v_i_1,,v_i_2]]
where the face_index refers to the original defining inequality.
For a given face, the collection of triangles formed by each
triple of v_i should triangulate that face.
This is computed by randomly lifting each face up a dimension; this does not always work!

NOTE:
    The doctest below is very weak, since it does not have to create a triangulation.

EXAMPLES:
    sage: p = Polyhedron(vertices = [[5,0,0],[0,5,0],[5,5,0],[2,2,5]])
    sage: len(p.triangulated_facial_incidences())
    4

render_wireframe(self)

source code 

For polytopes in 2 or 3 dimensions, returns the edges
as a list of lines.

EXAMPLES:
    sage: p = Polyhedron([[1,2,],[1,1],[0,0]])
    sage: p_wireframe = p.render_wireframe()
    sage: p_wireframe._Graphics__objects
    [Line defined by 2 points, Line defined by 2 points, Line defined by 2 points]