Ask Your Question

Vertex list of a surface not readily accessible

asked 2020-05-28 08:58:33 -0500

Juanjo gravatar image

While preparing my answer to this question, I have been searching how to retrieve faces and vertices from a explicit surface plotted with plot3d. There is a fact that confuses me. Consider this code:

sage: surf = plot3d(lambda x,y: sin(x*y), (-pi,pi), (-pi,pi))
sage: len(surf.vertex_list())

This means that surf.vertex_list() is an empty list. However:

sage: surf = plot3d(lambda x,y: sin(x*y), (-pi,pi), (-pi,pi))
sage: show(surf)
Launched html viewer for Graphics3d Object
sage: len(surf.vertex_list())

Now surf.vertex_list() is not an empty list and the vertices can be retrieved. So I wonder what show(surf) internally does so that the vertices list becomes accessible. To avoid plotting the surface, I have found that I can replace show(surf) by surf.triangulate(), but I also wonder if there is a best option.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2020-05-28 13:53:27 -0500

FrédéricC gravatar image

The ".triangulate" method does the real job of creating the triangulation. Before it is called, there is no vertex and no triangle.

edit flag offensive delete link more


So show calls the .triangulate method while rendering the surface. I have not been able to track down how that happens exactly. Anyway, I see that the code in the other question is essentially correct. @FrédéricC, many thanks for your comment.

Juanjo gravatar imageJuanjo ( 2020-05-28 15:16:00 -0500 )edit

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2020-05-28 08:58:33 -0500

Seen: 38 times

Last updated: May 28