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, 01 Oct 2010 18:43:44 +0200show polyhedron in an interacthttps://ask.sagemath.org/question/7718/show-polyhedron-in-an-interact/Hi, I am trying to write an interact which lets the user enter a list of vertices and then shows the corresponding polyhedron.
My first attempt is the following. The problem is that Sage does not show the polyhedron.
@interact
def _(t1=text_control("Polyhedron"), vertices="[[1,0],[0,1],[0,0]]"):
p=Polyhedron(vertices=eval(vertices))
show(p)
Does anybody know how to fix this?
Thanks.Fri, 01 Oct 2010 18:14:58 +0200https://ask.sagemath.org/question/7718/show-polyhedron-in-an-interact/Answer by mhampton for <p>Hi, I am trying to write an interact which lets the user enter a list of vertices and then shows the corresponding polyhedron. </p>
<p>My first attempt is the following. The problem is that Sage does not show the polyhedron.</p>
<pre><code>@interact
def _(t1=text_control("Polyhedron"), vertices="[[1,0],[0,1],[0,0]]"):
p=Polyhedron(vertices=eval(vertices))
show(p)
</code></pre>
<p>Does anybody know how to fix this?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/7718/show-polyhedron-in-an-interact/?answer=11707#post-id-11707I don't completely understand why this is happening, but to work around it you can use the Polyhedron's projection method (the most flexible solution) or more simply the render_solid and render_wireframe methods. For example:
@interact
def _(t1=text_control("Polyhedron"), vertices="[[1,0],[0,1],[0,0]]"):
p=Polyhedron(vertices=eval(vertices))
show(p.render_solid(rgbcolor='green')+p.render_wireframe(rgbcolor='red'))Fri, 01 Oct 2010 18:43:44 +0200https://ask.sagemath.org/question/7718/show-polyhedron-in-an-interact/?answer=11707#post-id-11707