Ask Your Question
0

using interact and canvas 3d

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

anonymous user

Anonymous

updated 2012-07-26 13:39:06 +0200

calc314 gravatar image

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()[2]

          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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-07-26 13:44:47 +0200

calc314 gravatar image

updated 2012-07-26 14:08:03 +0200

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.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

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

Seen: 308 times

Last updated: Jul 26 '12