canvas3d: displaying labels on axes and more

asked 2012-07-30 03:03:21 -0500

glee2 gravatar image

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

kcrisman gravatar image

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,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"),
      u = slider(0, P.nfacets()-1, step_size=1, default=None, label="Nominate a facet")): 
          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
edit retag flag offensive close merge delete

Comments

Actually, nevermind- I've solved the error but I still don't know about the axes... is there a way to put labels?

glee2 gravatar imageglee2 ( 2012-07-30 10:36:15 -0500 )edit

If you figured out how to solve it, please put your solution as an answer so others will be able to benefit from it!

kcrisman gravatar imagekcrisman ( 2012-07-31 03:34:39 -0500 )edit

As to the axes, my sense is that there probably is a way to do it but that we haven't wrapped it. You could try placing 3d text objects at specific positions and see if they work.

kcrisman gravatar imagekcrisman ( 2012-07-31 03:35:29 -0500 )edit