ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 31 Jul 2012 03:35:29 -0500canvas3d: displaying labels on axes and morehttp://ask.sagemath.org/question/9189/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,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_vMon, 30 Jul 2012 03:03:21 -0500http://ask.sagemath.org/question/9189/canvas3d-displaying-labels-on-axes-and-more/Comment by glee2 for <p>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. </p>
<p>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?</p>
<p>Thank you</p>
<hr/>
<pre><code>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
</code></pre>
http://ask.sagemath.org/question/9189/canvas3d-displaying-labels-on-axes-and-more/?comment=19311#post-id-19311Actually, nevermind- I've solved the error but I still don't know about the axes... is there a way to put labels?Mon, 30 Jul 2012 10:36:15 -0500http://ask.sagemath.org/question/9189/canvas3d-displaying-labels-on-axes-and-more/?comment=19311#post-id-19311Comment by kcrisman for <p>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. </p>
<p>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?</p>
<p>Thank you</p>
<hr/>
<pre><code>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
</code></pre>
http://ask.sagemath.org/question/9189/canvas3d-displaying-labels-on-axes-and-more/?comment=19308#post-id-19308If you figured out how to solve it, please put your solution as an answer so others will be able to benefit from it!Tue, 31 Jul 2012 03:34:39 -0500http://ask.sagemath.org/question/9189/canvas3d-displaying-labels-on-axes-and-more/?comment=19308#post-id-19308Comment by kcrisman for <p>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. </p>
<p>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?</p>
<p>Thank you</p>
<hr/>
<pre><code>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
</code></pre>
http://ask.sagemath.org/question/9189/canvas3d-displaying-labels-on-axes-and-more/?comment=19307#post-id-19307As 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.Tue, 31 Jul 2012 03:35:29 -0500http://ask.sagemath.org/question/9189/canvas3d-displaying-labels-on-axes-and-more/?comment=19307#post-id-19307