Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

canvas3d: displaying labels on axes and more

Is there a way to show the labels and numbers on the axes when plotting wireframe polygons in canvas3d? (so that the display is more like Jmol) So far I've managed the axes to be shown but there are no labels and there is no benefit from displaying it.

Also, I'm trying to make sage print the coordinates of the vertices of the selected facet... this code displays "'_PolytopeFace' object is not callable" error. I need sage to print the coordinates so that I can use this to plot tiny spheres at the vertices (as canvas3d doesn't allow you to print points...). Is there a more efficient way of going about it?

Thank you


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 facets = P.faces()[3]

@interact

def _(theta_one = slider(0,2pi,pi/20, default = pi/4, label="theta_one"), theta_two = slider(0,2pi,pi/20, default = pi/4, label="theta_two"), phi = slider(0,2pi,pi/20, default = pi/4, label="phi"), u = slider(0, P.nfacets()-1, step_size=1, default=None, label="Nominate a facet")): a=rsin(theta_one)sin(theta_two)cos(phi) b=rsin(theta_one)sin(theta_two)sin(phi) c=rsin(theta_one)cos(theta_two) d=rcos(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, )


      ff = facets[u]
      print ff

      selected_v = [ff(i) for i in projected_vertices]
      print selected_v
click to hide/show revision 2
No.2 Revision

updated 2012-07-30 03:18:43 -0500

kcrisman gravatar image

canvas3d: displaying labels on axes and more

Is there a way to show the labels and numbers on the axes when plotting wireframe polygons in canvas3d? (so that the display is more like Jmol) So far I've managed the axes to be shown but there are no labels and there is no benefit from displaying it.

Also, I'm trying to make sage print the coordinates of the vertices of the selected facet... this code displays "'_PolytopeFace' object is not callable" error. I need sage to print the coordinates so that I can use this to plot tiny spheres at the vertices (as canvas3d doesn't allow you to print points...). Is there a more efficient way of going about it?

Thank you


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
facets = P.faces()[3]

P.faces()[3] @interact

def _(theta_one = slider(0,2pi,pi/20, slider(0,2*pi,pi/20, default = pi/4, label="theta_one"), theta_two = slider(0,2pi,pi/20, slider(0,2*pi,pi/20, default = pi/4, label="theta_two"), phi = slider(0,2pi,pi/20, slider(0,2*pi,pi/20, default = pi/4, label="phi"), u = slider(0, P.nfacets()-1, step_size=1, default=None, label="Nominate a facet")): a=rsin(theta_one)sin(theta_two)cos(phi) b=rsin(theta_one)sin(theta_two)sin(phi) c=rsin(theta_one)cos(theta_two) d=rcos(theta_one)

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, )


       ff = facets[u]
       print ff

       selected_v = [ff(i) for i in projected_vertices]
       print selected_v