# Computing projection of a polyhedron

How to compute the projection of a given polyhedron onto a given smaller-dimensional plane?

E.g., the projection of Polyhedron(vertices=[(-1,-1), (1,3), (5,-2)]) onto the line $y=x$.

edit retag close merge delete

Sort by » oldest newest most voted

One possibility is the following.

First create the desired transformation as a matrix.

sage: nf = QuadraticField(2)
sage: sqrt2 = nf.gen()
sage: proj_mat = matrix(nf,[[sqrt2/2,sqrt2/2],[sqrt2/2,sqrt2/2]])


sage: P = Polyhedron(vertices=[(-1,-1), (1,3), (5,-2)])


One then just need to apply the transformation on each vertices of the polyhedron and take the result back to a polyhedron.

sage: Pproj = Polyhedron(vertices = (proj_mat*P.vertices_matrix()).columns())
sage: Pproj
A 1-dimensional polyhedron in (Number Field in a with defining polynomial x^2 - 2)^2 defined as the convex hull of 2 vertices
sage: Pproj.vertices_list()
[[-a, -a], [2*a, 2*a]]


Currently, projections (or other linear transformations) are not implemented better than as above...

more

In sage 9.1 one can skip the third part by just multiplying the matrix with the polyhedron: proj_mat*P.

The following answer should give you a step by step guide: https://ask.sagemath.org/question/354...

In particular how to obtain the matrix that induces a projection to an affine span.