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.Fri, 22 Feb 2013 12:06:52 -0600Intersection of a hyperplane with a polytope (intersection in 9D)https://ask.sagemath.org/question/9829/intersection-of-a-hyperplane-with-a-polytope-intersection-in-9d/Hi,
I have a hyperplane given by equation:
2/3*x1 + 2/3*x2 + 2/3*x3 - 1/3*x4 - 1/3*x5 - 1/3*x6 - 1/3*x7 -1/3*x8 - 1/3*x9 = 1
and a polytope with nine vertices:
P = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [-8/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9], [-7/9, -7/9, 2/9, 2/9, 2/9, 2/9, 2/9, 2/9, 2/9], [-2/3, -2/3, -2/3, 1/3, 1/3, 1/3, 1/3, 1/3, 1/3], [-5/9, -5/9, -5/9, -5/9, 4/9, 4/9, 4/9, 4/9, 4/9], [-4/9, -4/9, -4/9, -4/9, -4/9, 5/9, 5/9, 5/9, 5/9], [-1/3, -1/3, -1/3, -1/3, -1/3, -1/3, 2/3, 2/3, 2/3], [-2/9, -2/9, -2/9, -2/9, -2/9, -2/9, -2/9, 7/9, 7/9], [-1/9, -1/9, -1/9, -1/9, -1/9, -1/9, -1/9, -1/9, 8/9]]
Each vertex in this polytope is connected to other eight vertices with a line.
I have tried with the following approach but I am unable to get the correct result.
First I created a polyhedron from the equation of the hyperplane as follows:
Hplane1 = Polyhedron(eqns=[(-3,2,2,2,-1,-1,-1,-1,-1,-1)])
Next I used this code to find the intersection between hyperplane and the line connected by every two vertices of the Polytope 'P'
for j in range(len(P)):
for i in range(len(P)):
if i != j:
a = Polyhedron( vertices = [P[i], P[j]])
b = a.intersection(Hplane1)
print(b)
I know the this hyperplane and the polytope have some intersection points but I am unable to calculate them. Any help/suggestion will be highly appreciated.
ThanksThu, 21 Feb 2013 17:27:14 -0600https://ask.sagemath.org/question/9829/intersection-of-a-hyperplane-with-a-polytope-intersection-in-9d/Answer by lftabera for <p>Hi,</p>
<p>I have a hyperplane given by equation:</p>
<p>2/3<em>x1 + 2/3</em>x2 + 2/3<em>x3 - 1/3</em>x4 - 1/3<em>x5 - 1/3</em>x6 - 1/3<em>x7 -1/3</em>x8 - 1/3*x9 = 1</p>
<p>and a polytope with nine vertices:</p>
<p>P = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [-8/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9], [-7/9, -7/9, 2/9, 2/9, 2/9, 2/9, 2/9, 2/9, 2/9], [-2/3, -2/3, -2/3, 1/3, 1/3, 1/3, 1/3, 1/3, 1/3], [-5/9, -5/9, -5/9, -5/9, 4/9, 4/9, 4/9, 4/9, 4/9], [-4/9, -4/9, -4/9, -4/9, -4/9, 5/9, 5/9, 5/9, 5/9], [-1/3, -1/3, -1/3, -1/3, -1/3, -1/3, 2/3, 2/3, 2/3], [-2/9, -2/9, -2/9, -2/9, -2/9, -2/9, -2/9, 7/9, 7/9], [-1/9, -1/9, -1/9, -1/9, -1/9, -1/9, -1/9, -1/9, 8/9]]</p>
<p>Each vertex in this polytope is connected to other eight vertices with a line. </p>
<p>I have tried with the following approach but I am unable to get the correct result. </p>
<p>First I created a polyhedron from the equation of the hyperplane as follows:</p>
<p>Hplane1 = Polyhedron(eqns=[(-3,2,2,2,-1,-1,-1,-1,-1,-1)])</p>
<p>Next I used this code to find the intersection between hyperplane and the line connected by every two vertices of the Polytope 'P'</p>
<p>for j in range(len(P)):</p>
<pre><code> for i in range(len(P)):
if i != j:
a = Polyhedron( vertices = [P[i], P[j]])
b = a.intersection(Hplane1)
print(b)
</code></pre>
<p>I know the this hyperplane and the polytope have some intersection points but I am unable to calculate them. Any help/suggestion will be highly appreciated.</p>
<p>Thanks</p>
https://ask.sagemath.org/question/9829/intersection-of-a-hyperplane-with-a-polytope-intersection-in-9d/?answer=14580#post-id-14580You can compute directly the intersection of the hyperplane and the polyhedron
sage: Hplane1 = Polyhedron(eqns=[(-3,2,2,2,-1,-1,-1,-1,-1,-1)])
sage: P = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [-8/9, 1/9, 1/9, 1/9, ...
sage: P1 = Polyhedron(P)
sage: P1.intersection(Hplane1)
The empty polyhedron in QQ^9
So it looks that the hyperplane does not intersect your polyhedron.Fri, 22 Feb 2013 12:06:52 -0600https://ask.sagemath.org/question/9829/intersection-of-a-hyperplane-with-a-polytope-intersection-in-9d/?answer=14580#post-id-14580