First time here? Check out the FAQ!

Ask Your Question
1

Vertex list of a surface not readily accessible

asked 4 years ago

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())
0

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())
1600

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 4 years ago

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.

Preview: (hide)
link

Comments

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 ( 4 years ago )

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

Stats

Asked: 4 years ago

Seen: 286 times

Last updated: May 28 '20