Ask Your Question

# using interact and canvas 3d Anonymous

Hi, I'm not sure what I'm doing wrong but my code doesn't seem to be working. I have no errors when I run this code but the input box doesn't appear at all...

P = LatticePolytope([[1,2,3,4],[5,2,5,6],[2,2,5,2],[-3,-2,-5,-1],[-2,-2,-2,-1]])
from sage.geometry.polyhedron.plot import ProjectionFuncStereographic
r=7
@interact
def _(theta_one = slider(0,2*pi,pi/20, default = pi/4, label="theta_one"),
theta_two = slider(0,2*pi,pi/20, default = pi/4, label="theta_two"),
phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
a=r*sin(theta_one)*sin(theta_two)*cos(phi)
b=r*sin(theta_one)*sin(theta_two)*sin(phi)
c=r*sin(theta_one)*cos(theta_two)
d=r*cos(theta_one)

proj = ProjectionFuncStereographic([a,b,c,d])
projected_vertices = [proj(v) for v in P.vertices().columns()]
faces = P.faces()

faces_as_vertex_lists = [[projected_vertices[n] for n in face.traverse_boundary()] for face in faces]
scene = Graphics()
for vert_list in faces_as_vertex_lists:
scene = scene + polygon3d(vert_list, color='blue')

scene.show(viewer='canvas3d', axes=True)

def highlight_facet(facet_index = input_box(x, label="facet index")):
facet_index = P.facets()[x]
if facet_index == False:
print "this facet does not exist"
if facet_index == True:
V = [projected_vertices(n) for n in facet_index]
print V

edit retag close merge delete

## 1 Answer

Sort by » oldest newest most voted

I think you'll need to incorporate the input box into your first function definition with the sliders. Then, you can call your highlight_facet function (which should be defined prior to the first function) within this first function definition with the input facet_index.

more

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2012-07-26 12:31:49 +0200

Seen: 203 times

Last updated: Jul 26 '12