# Polyhedron -- the class of all convex polyhedra

## Description

A Polyhedron represents a rational polyhedron. It can be bounded or unbounded, need not be full dimensional or may contain a proper affine subspace. It can be empty or zero dimensional. It is saved as a hash table which contains the vertices, generating rays, and the basis of the lineality space of the Polyhedron as well as the defining affine half-spaces and hyperplanes. The output of a Polyhedron looks like this:
 ```i1 : convexHull(matrix {{0,0,-1,-1},{2,-2,1,-1},{0,0,0,0}},matrix {{1},{0},{0}}) o1 = Polyhedron{...1...} o1 : Polyhedron```

This table displays a short summary of the properties of the Polyhedron. Note that the number of rays and vertices are modulo the lineality space. So for example a line in QQ^2 has one vertex and no rays. However, one can not access the above information directly, because this is just a virtual hash table generated for the output. The data defining a Polyhedron is extracted by the functions included in this package. A Polyhedron can be constructed as the convex hull (convexHull) of a set of points and a set of rays or as the intersection (polyhedronFromHData) of a set of affine half-spaces and affine hyperplanes.

For example, consider the square and the square with an emerging ray for the convex hull:

 ```i2 : V = matrix {{1,1,-1,-1},{1,-1,1,-1}} o2 = | 1 1 -1 -1 | | 1 -1 1 -1 | 2 4 o2 : Matrix ZZ <--- ZZ``` ```i3 : convexHull V o3 = Polyhedron{...1...} o3 : Polyhedron``` ```i4 : R = matrix {{1},{1}} o4 = | 1 | | 1 | 2 1 o4 : Matrix ZZ <--- ZZ``` ```i5 : convexHull(V,R) o5 = Polyhedron{...1...} o5 : Polyhedron```

If we take the intersection of the half-spaces defined by the directions of the vertices and 1 we get the crosspolytope:

 ```i6 : HS = transpose V o6 = | 1 1 | | 1 -1 | | -1 1 | | -1 -1 | 4 2 o6 : Matrix ZZ <--- ZZ``` ```i7 : v = R || R o7 = | 1 | | 1 | | 1 | | 1 | 4 1 o7 : Matrix ZZ <--- ZZ``` ```i8 : P = polyhedronFromHData(HS,v) o8 = P o8 : Polyhedron``` ```i9 : vertices P o9 = | -1 1 0 0 | | 0 0 -1 1 | 2 4 o9 : Matrix QQ <--- QQ```

This can for example be embedded in 3-space on height 1:

 ```i10 : HS = HS | matrix {{0},{0},{0},{0}} o10 = | 1 1 0 | | 1 -1 0 | | -1 1 0 | | -1 -1 0 | 4 3 o10 : Matrix ZZ <--- ZZ``` ```i11 : hyperplanesTmp = matrix {{0,0,1}} o11 = | 0 0 1 | 1 3 o11 : Matrix ZZ <--- ZZ``` ```i12 : w = matrix {{1}} o12 = | 1 | 1 1 o12 : Matrix ZZ <--- ZZ``` ```i13 : P = polyhedronFromHData(HS,v,hyperplanesTmp,w) o13 = P o13 : Polyhedron``` ```i14 : vertices P o14 = | -1 1 0 0 | | 0 0 -1 1 | | 1 1 1 1 | 3 4 o14 : Matrix QQ <--- QQ```

## Functions and methods returning a convex polyhedron :

• affineHull -- computes the affine hull of a polyhedron
• affineImage -- computes the affine image of a cone or polyhedron
• affinePreimage -- computes the affine preimage of a cone or polyhedron
• bipyramid -- computes the bipyramid over a polyhedron
• convexHull -- computing the convex hull of points, rays and polyhedra
• crossPolytope -- computes the d-dimensional crosspolytope with diameter 2s
• cyclicPolytope -- computes the d dimensional cyclic polytope with n vertices
• emptyPolyhedron -- generates the empty polyhedron in n-space
• hypercube -- Returns the d-dimensional hypercube
• minkowskiSum -- computes the Minkowski sum of two convex objects
• newtonPolytope -- computes the Newton polytope of a polynomial
• polar -- computes the polar of a polyhedron
• polarFace -- computes the dual face of the polar polyhedron
• polytope -- returns a polytope of which the fan is the normal fan if it is polytopal
• pyramid -- computes the pyramid over a polyhedron
• secondaryPolytope -- computes the secondary polytope of a compact polyhedron
• simplex -- Produces a full-dimensional simplex
• statePolytope -- computes the state polytope of a homogeneous ideal
• stdSimplex -- generates the d-dimensional standard simplex

## Methods that use a convex polyhedron :

• affineHull(Polyhedron), see affineHull -- computes the affine hull of a polyhedron
• affineImage(Matrix,Polyhedron), see affineImage(Matrix,Polyhedron,Matrix) -- computes the affine image of a polyhedron
• affineImage(Matrix,Polyhedron,Matrix) -- computes the affine image of a polyhedron
• affineImage(Polyhedron,Matrix), see affineImage(Matrix,Polyhedron,Matrix) -- computes the affine image of a polyhedron
• affinePreimage(Matrix,Polyhedron), see affinePreimage(Matrix,Polyhedron,Matrix) -- computes the affine preimage of a polyhedron
• affinePreimage(Matrix,Polyhedron,Matrix) -- computes the affine preimage of a polyhedron
• affinePreimage(Polyhedron,Matrix), see affinePreimage(Matrix,Polyhedron,Matrix) -- computes the affine preimage of a polyhedron
• areCompatible(Polyhedron,Polyhedron), see areCompatible -- checks if the intersection of two cones/polyhedra is a face of each
• barycentricTriangulation(Polyhedron), see barycentricTriangulation -- computes a triangulation of a polytope
• bipyramid(Polyhedron), see bipyramid -- computes the bipyramid over a polyhedron
• cellDecompose(Polyhedron,Matrix), see cellDecompose -- Deprecated variant of {\tt regularSubdivision}
• commonFace(Polyhedron,Polyhedron), see commonFace -- checks if the intersection is a face of both Cones or Polyhedra, or of cones with fans
• Cone * Polyhedron -- computes the direct product of a cone and a polyhedron
• Cone + Polyhedron -- computes the Minkowski sum of a cone and a polyhedron
• cone(Polyhedron) -- Take the cone over a polyhedron
• coneFromVData(Polyhedron), see coneFromVData -- computes the positive hull of rays, cones, and the cone over a polyhedron
• contains(Cone,Polyhedron), see contains -- checks if the first argument contains the second argument
• contains(List,Polyhedron), see contains -- checks if the first argument contains the second argument
• contains(Polyhedron,Cone), see contains -- checks if the first argument contains the second argument
• contains(Polyhedron,Matrix), see contains -- checks if the first argument contains the second argument
• contains(Polyhedron,Polyhedron), see contains -- checks if the first argument contains the second argument
• convexHull(Polyhedron,Polyhedron), see convexHull -- computing the convex hull of points, rays and polyhedra
• directProduct(Cone,Polyhedron), see directProduct(Cone,Cone) -- computes the direct product of polyhedra and cones
• directProduct(Polyhedron,Cone), see directProduct(Cone,Cone) -- computes the direct product of polyhedra and cones
• directProduct(Polyhedron,Polyhedron), see directProduct(Cone,Cone) -- computes the direct product of polyhedra and cones
• dualFaceRepresentationMap(Polyhedron) (missing documentation)
• ehrhart(Polyhedron), see ehrhart -- calculates the Ehrhart polynomial of a polytope
• faceFan(Polyhedron), see faceFan -- computes the fan generated by the cones over the faces
• facesAsPolyhedra(ZZ,Polyhedron), see facesAsPolyhedra -- Returns the faces of a polyhedron as actual polyhedra.
• facets(Polyhedron), see facets -- Giving the facet inequalities of a cone or polyhedron.
• halfspaces(Polyhedron), see halfspaces -- computes the defining half-spaces of a Cone or a Polyhedron
• hyperplanes(Polyhedron), see hyperplanes -- computes the defining hyperplanes of a Cone or a Polyhedron
• incompPolyhedra(PolyhedralComplex,Polyhedron), see incompPolyhedra -- returns the pairs of incompatible polyhedra
• incompPolyhedra(Polyhedron,PolyhedralComplex), see incompPolyhedra -- returns the pairs of incompatible polyhedra
• inInterior(Matrix,Polyhedron), see inInterior -- checks if a point lies in the relative interior of a Cone/Polyhedron
• interiorLatticePoints(Polyhedron), see interiorLatticePoints -- computes the lattice points in the relative interior of a polytope
• interiorPoint(Polyhedron), see interiorPoint -- computes a point in the relative interior of the Polyhedron
• intersection(Cone,Polyhedron), see intersection -- computes the intersection of cones, and polyhedra
• intersection(Polyhedron,Cone), see intersection -- computes the intersection of cones, and polyhedra
• intersection(Polyhedron,Polyhedron), see intersection -- computes the intersection of cones, and polyhedra
• isCompact(Polyhedron), see isCompact -- checks compactness of a Polyhedron
• isEmpty(Polyhedron), see isEmpty -- checks if a Polyhedron is empty
• isFace(Polyhedron,Polyhedron), see isFace -- tests if the first argument is a face of the second
• isLatticePolytope(Polyhedron), see isLatticePolytope -- checks if a polyhedron is a lattice polytope
• isNormal(Polyhedron) -- checks if a polytope is normal in the ambient lattice
• isReflexive(Polyhedron), see isReflexive -- checks if a Polytope is reflexive
• isVeryAmple(Polyhedron), see isVeryAmple -- checks if the Polyhedron is very ample
• isWellDefined(Polyhedron), see isWellDefined(Cone) -- Checks whether a polyhedral object is well-defined.
• latticePoints(Polyhedron), see latticePoints -- computes the lattice points of a polytope
• latticeVolume(Polyhedron), see latticeVolume -- Returning the lattice volume of a polyhedron.
• linSpace(Polyhedron), see linSpace -- Deprecated version of @TO "linealitySpace"@
• maxFace(Matrix,Polyhedron), see maxFace -- computes the face of a Polyhedron or Cone where a weight attains its maximum
• minFace(Matrix,Polyhedron), see minFace -- computes the face of a Polyhedron or Cone where a weight attains its minimum
• minkowskiSum(Cone,Polyhedron), see minkowskiSum -- computes the Minkowski sum of two convex objects
• minkowskiSum(Polyhedron,Cone), see minkowskiSum -- computes the Minkowski sum of two convex objects
• minkowskiSum(Polyhedron,Polyhedron), see minkowskiSum -- computes the Minkowski sum of two convex objects
• minkSummandCone(Polyhedron), see minkSummandCone -- computes the Cone of all Minkowski summands and the minimal decompositions
• normalCone(Polyhedron,Polyhedron) -- computes the normal cone of a face of a polyhedron
• normalFan(Polyhedron), see normalFan -- computes the normalFan of a polyhedron
• nVertices(Polyhedron), see nVertices -- Returns the number of vertices of a polyhedron
• objectiveVector(Polyhedron,Polyhedron), see objectiveVector -- computes an objective vector of a face of a polyhedron
• polar(Polyhedron), see polar -- computes the polar of a polyhedron
• polarFace(Polyhedron,Polyhedron), see polarFace -- computes the dual face of the polar polyhedron
• polyhedralComplex(Polyhedron), see polyhedralComplex -- generates a PolyhedralComplex
• Polyhedron * Cone -- computes the direct product of a polyhedron and a cone
• Polyhedron * Polyhedron -- computes the direct product of two polyhedra
• Polyhedron + Cone -- computes the Minkowski sum of a polyhedron and a cone
• Polyhedron + Polyhedron -- computes the Minkowski sum of two polyhedra
• Polyhedron == Polyhedron -- equality
• proximum(Matrix,Polyhedron), see proximum -- computes the proximum of the Polyhedron/Cone to a point in euclidian metric
• pyramid(Polyhedron), see pyramid -- computes the pyramid over a polyhedron
• QQ * Polyhedron -- rescales a polyhedron by a given positive factor
• ZZ * Polyhedron, see QQ * Polyhedron -- rescales a polyhedron by a given positive factor
• regularSubdivision(Polyhedron,Matrix), see regularSubdivision -- Computes the regular cell decomposition
• regularTriangulation(Polyhedron), see regularTriangulation -- Computes a regular triangulation of a given polytope.
• secondaryPolytope(Polyhedron), see secondaryPolytope -- computes the secondary polytope of a compact polyhedron
• smallestFace(Matrix,Polyhedron), see smallestFace -- determines the smallest face of the Cone/Polyhedron containing a point
• sublatticeBasis(Polyhedron), see sublatticeBasis -- computes a basis for the sublattice generated by integral vectors or the lattice points of a polytope
• tailCone(Polyhedron), see tailCone -- computes the tail/recession cone of a polyhedron
• toSublattice(Polyhedron), see toSublattice -- calculates the preimage of a polytope in the sublattice generated by its lattice points
• triangulate(Polyhedron), see triangulate -- Deprecated name for {\tt barycentricTriangulation}
• vertexEdgeMatrix(Polyhedron), see vertexEdgeMatrix -- computes the vertex-edge-relations matrix
• vertexFacetMatrix(Polyhedron), see vertexFacetMatrix -- computes the vertex-facet-relations matrix
• vertices(Polyhedron), see vertices -- displays the vertices of a Polyhedron or a PolyhedralComplex
• volume(Polyhedron), see volume -- computes the volume of a polytope

## For the programmer

The object Polyhedron is a type, with ancestor classes PolyhedralObject < MutableHashTable < HashTable < Thing.