ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 02 Aug 2012 15:33:47 -0500CUBE+PLANES = POLYHEDRONShttps://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/I have an cube and an collention of planes ( normal and one point, Ax = b ). how can I get the polyhedrons formed by the intersection of the cube and the planes? Tue, 31 Jul 2012 09:21:52 -0500https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/Answer by Volker Braun for <p>I have an cube and an collention of planes ( normal and one point, Ax = b ). how can I get the polyhedrons formed by the intersection of the cube and the planes? </p>
https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/?answer=13878#post-id-13878Define the cube as a polyhedron (its a canned example):
sage: cube = polytopes.n_cube(3)
sage: cube.Hrepresentation()
(An inequality (0, 0, -1) x + 1 >= 0, An inequality (0, -1, 0) x + 1 >= 0, An inequality (-1, 0, 0) x + 1 >= 0, An inequality (1, 0, 0) x + 1 >= 0, An inequality (0, 0, 1) x + 1 >= 0, An inequality (0, 1, 0) x + 1 >= 0)
Define the plane as a polyhedron:
sage: plane = Polyhedron(eqns=[(0,1,0,0)])
sage: plane.Hrepresentation()
(An equation (1, 0, 0) x + 0 == 0,)
Compute the intersection:
sage: cube.intersection(plane)
A 2-dimensional polyhedron in QQ^3 defined as the convex hull of 4 vertices
Tue, 31 Jul 2012 11:56:51 -0500https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/?answer=13878#post-id-13878Comment by mfa for <p>Define the cube as a polyhedron (its a canned example):</p>
<pre><code>sage: cube = polytopes.n_cube(3)
sage: cube.Hrepresentation()
(An inequality (0, 0, -1) x + 1 >= 0, An inequality (0, -1, 0) x + 1 >= 0, An inequality (-1, 0, 0) x + 1 >= 0, An inequality (1, 0, 0) x + 1 >= 0, An inequality (0, 0, 1) x + 1 >= 0, An inequality (0, 1, 0) x + 1 >= 0)
</code></pre>
<p>Define the plane as a polyhedron:</p>
<pre><code>sage: plane = Polyhedron(eqns=[(0,1,0,0)])
sage: plane.Hrepresentation()
(An equation (1, 0, 0) x + 0 == 0,)
</code></pre>
<p>Compute the intersection:</p>
<pre><code>sage: cube.intersection(plane)
A 2-dimensional polyhedron in QQ^3 defined as the convex hull of 4 vertices
</code></pre>
https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/?comment=19299#post-id-19299Thanks for the response: the plane intersects or cut to the cube generating two polyhedra, so how could get these polihedros to manipulate?Wed, 01 Aug 2012 06:39:52 -0500https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/?comment=19299#post-id-19299Answer by mfa for <p>I have an cube and an collention of planes ( normal and one point, Ax = b ). how can I get the polyhedrons formed by the intersection of the cube and the planes? </p>
https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/?answer=13882#post-id-13882Thanks for the reponse: in the above solution, the plane intersects or cut to the cube generating two polyhedra, so how could get these polihedros to manipulate?Tue, 31 Jul 2012 15:30:20 -0500https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/?answer=13882#post-id-13882Comment by mfa for <p>Thanks for the reponse: in the above solution, the plane intersects or cut to the cube generating two polyhedra, so how could get these polihedros to manipulate?</p>
https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/?comment=19292#post-id-19292may not explain well . I have a polyhedron and I need to cut it with several planes and I want to count the number of generated polihedros and I also need to drawThu, 02 Aug 2012 15:33:47 -0500https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/?comment=19292#post-id-19292Comment by Volker Braun for <p>Thanks for the reponse: in the above solution, the plane intersects or cut to the cube generating two polyhedra, so how could get these polihedros to manipulate?</p>
https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/?comment=19298#post-id-19298I don't understand your question. The intersection of two convex sets is always a single convex set (perhaps empty).Wed, 01 Aug 2012 15:18:54 -0500https://ask.sagemath.org/question/9197/cubeplanes-polyhedrons/?comment=19298#post-id-19298