Ask Your Question

Can I intersect the boundaries of two polyhedra and display it?

asked 2015-04-19 16:38:58 -0500

RoyJac gravatar image

I need to show the intersection of two polyhedra's facets (orthoplexes for this case). Any nice way to do that?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-04-19 16:51:20 -0500

updated 2015-04-19 17:19:32 -0500


Given a polyhedron you can obtain their faces with the method faces. Then you can convert them to polyhedra and intersect them. In action

sage: P1 = Polyhedron([(0,0),(1,2),(3,4)])
sage: P2 = Polyhedron([(0,0),(1,2),(-3,-2)])
sage: f1 = [f.as_polyhedron() for f in P1.faces(1)]
sage: f2 = [f.as_polyhedron() for f in P2.faces(1)]

f1 is just the faces of my first polyhedron (seen themselves as polyhedra)

sage: f1[0].vertices_list()
[[0, 0], [1, 2]]
sage: f1[1].vertices_list()
[[0, 0], [3, 4]]
sage: f1[2].vertices_list()
[[1, 2], [3, 4]]

idem for f2

sage: f2[0].vertices_list()
[[-3, -2], [0, 0]]
sage: f2[1].vertices_list()
[[-3, -2], [1, 2]]
sage: f2[2].vertices_list()
[[0, 0], [1, 2]]

And you can now do intersection between them

sage: f1[0].intersection(f2[0])
A 0-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex
sage: f1[0].intersection(f2[2])
A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices

Then, for plotting a polyhedra P just do P.plot() or To see the options you have for plotting, you can have a look at the documentation obtained by typing enter after P.plot? or (with the question mark). There is also the possibility to make a tikz picture if you are interested.


edit flag offensive delete link more


Thanks! Helped a lot :)

RoyJac gravatar imageRoyJac ( 2015-04-20 11:45:20 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-04-19 16:38:58 -0500

Seen: 93 times

Last updated: Apr 19 '15