ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 07 Feb 2020 19:08:19 +0100Intersection of a Cube with two planes and resulting polyhedronhttps://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/Hi,
I am new to sage and trying to solve a problem where I have two planes cutting a cube. How can I find the resulting polytope/polyhedron as a result of this cut.
cube = polytopes.n_cube(3)
cube.Hrepresentation()
plane1 = Polyhedron(eqns=[(0,1,0,0)])
plane2 = Polyhedron(eqns=[(1,0,0,-1)])
Please also tell me that what is meant by `eqns=[(0,1,0,0)]` in sage? what equality it represent? similarly `eqns=[(1,0,0,-1)]` ?
Thanks
Tue, 19 Feb 2013 00:21:51 +0100https://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/Comment by fidbc for <p>Hi,</p>
<p>I am new to sage and trying to solve a problem where I have two planes cutting a cube. How can I find the resulting polytope/polyhedron as a result of this cut.</p>
<pre><code>cube = polytopes.n_cube(3)
cube.Hrepresentation()
plane1 = Polyhedron(eqns=[(0,1,0,0)])
plane2 = Polyhedron(eqns=[(1,0,0,-1)])
</code></pre>
<p>Please also tell me that what is meant by <code>eqns=[(0,1,0,0)]</code> in sage? what equality it represent? similarly <code>eqns=[(1,0,0,-1)]</code> ? </p>
<p>Thanks</p>
https://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/?comment=18218#post-id-18218The last example in the documentation might be useful to understand what `eqns` means. http://x0.no/apdeTue, 19 Feb 2013 09:49:11 +0100https://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/?comment=18218#post-id-18218Answer by twch for <p>Hi,</p>
<p>I am new to sage and trying to solve a problem where I have two planes cutting a cube. How can I find the resulting polytope/polyhedron as a result of this cut.</p>
<pre><code>cube = polytopes.n_cube(3)
cube.Hrepresentation()
plane1 = Polyhedron(eqns=[(0,1,0,0)])
plane2 = Polyhedron(eqns=[(1,0,0,-1)])
</code></pre>
<p>Please also tell me that what is meant by <code>eqns=[(0,1,0,0)]</code> in sage? what equality it represent? similarly <code>eqns=[(1,0,0,-1)]</code> ? </p>
<p>Thanks</p>
https://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/?answer=14562#post-id-14562For an answer of the interpretation of eqns see your first [post](http://ask.sagemath.org/question/2267/equalitiesinequalities-in-polyhedron).
in order to calculate the intersection of your two planes and the cube, you can simply put all conditions in a new Polyhedron
cube = polytopes.n_cube(3)
plane1 = Polyhedron(eqns=[(0,1,0,0)])
plane2 = Polyhedron(eqns=[(1,0,0,-1)])
intersec=Polyhedron(eqns=plane1.equations()+plane2.equations(), ieqs=cube.inequalities())
print intersec.Hrepresentation()
intersec.show()Tue, 19 Feb 2013 17:03:01 +0100https://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/?answer=14562#post-id-14562Comment by jipilab for <p>For an answer of the interpretation of eqns see your first <a href="http://ask.sagemath.org/question/2267/equalitiesinequalities-in-polyhedron">post</a>.</p>
<p>in order to calculate the intersection of your two planes and the cube, you can simply put all conditions in a new Polyhedron</p>
<pre><code>cube = polytopes.n_cube(3)
plane1 = Polyhedron(eqns=[(0,1,0,0)])
plane2 = Polyhedron(eqns=[(1,0,0,-1)])
intersec=Polyhedron(eqns=plane1.equations()+plane2.equations(), ieqs=cube.inequalities())
print intersec.Hrepresentation()
intersec.show()
</code></pre>
https://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/?comment=49847#post-id-49847In a more recent version you can do:
sage: cube = polytopes.cube()
sage: plane1 = Polyhedron(eqns=[(0,1,0,0)])
sage: plane2 = Polyhedron(eqns=[(1,0,0,-1)])
sage: intersec = cube & plane1 & plane2Fri, 07 Feb 2020 19:08:19 +0100https://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/?comment=49847#post-id-49847Answer by assadabbasi for <p>Hi,</p>
<p>I am new to sage and trying to solve a problem where I have two planes cutting a cube. How can I find the resulting polytope/polyhedron as a result of this cut.</p>
<pre><code>cube = polytopes.n_cube(3)
cube.Hrepresentation()
plane1 = Polyhedron(eqns=[(0,1,0,0)])
plane2 = Polyhedron(eqns=[(1,0,0,-1)])
</code></pre>
<p>Please also tell me that what is meant by <code>eqns=[(0,1,0,0)]</code> in sage? what equality it represent? similarly <code>eqns=[(1,0,0,-1)]</code> ? </p>
<p>Thanks</p>
https://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/?answer=14565#post-id-14565Thank you very much. Your explanation was very useful in solving my problem.Wed, 20 Feb 2013 18:01:10 +0100https://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/?answer=14565#post-id-14565