using interact and canvas 3d
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