Ask Your Question
1

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

asked 2015-04-19 23:38:58 +0100

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
2

answered 2015-04-19 23:51:20 +0100

vdelecroix gravatar image

updated 2015-04-20 00:19:32 +0100

Hello,

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 P.show(). To see the options you have for plotting, you can have a look at the documentation obtained by typing enter after P.plot? or P.show? (with the question mark). There is also the possibility to make a tikz picture if you are interested.

Vincent

edit flag offensive delete link more

Comments

Thanks! Helped a lot :)

RoyJac gravatar imageRoyJac ( 2015-04-20 18:45:20 +0100 )edit
2

You can also do the intersection operation by using "&":

sage: P1 & P2
jipilab gravatar imagejipilab ( 2018-07-05 13:47:46 +0100 )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

Stats

Asked: 2015-04-19 23:38:58 +0100

Seen: 671 times

Last updated: Apr 20 '15