A triangulate method that produces quadrilaterals. Why ?

49 views
Skip to first unread message

ams

unread,
Jan 12, 2017, 6:29:13 AM1/12/17
to sage-devel
While investigating the stl export from 3D plots, (which have been recently improved, see trac-ticket-22144) I found a method in plot/plot3d/parametric_surface.pyx that is called triangulate, but that actually quadrangulates the underlying self (maybe it also produces triangles, when some quadrilateral is degenerate, I am not sure).

def triangulate(self, render_params=None):
    r
"""
    […] so normals of the triangles
[…]
    """
    #
[…]       
        face.n = 4
# […]

The reason I looked into it was that it caused problem for saving to stl format because the old version of stl_ascii_string method assumed that the output of a method called triangulate would always have only triangles. stl_ascii_string have been modified in ticket 22144, but I still thing it's kind of counterintuitive to have a triangulate method that do not produces triangles but quadrilaterals instead.

Does anybody here knows what were the reasons behind this choice ? And where is it used ?

Frédéric Chapoton

unread,
Jan 12, 2017, 1:25:50 PM1/12/17
to sage-devel
Hello,

I think this is more subtle than that. The procedure "triangulate" is used in several places, and sometimes it may generate triangles.
When I wrote the old stl_ascii_string, I was lazy and did not care about faces other than triangles, even if I knew perfectly that they could happen. I have never seen any feedback on somebody using this STL export and saying "that's good to have", so my motivation was low.
I do not think that the name "triangulate" is good, but there is not much value in changing it. This is a rather deep internal method.

Frederic

ams

unread,
Jan 12, 2017, 2:57:11 PM1/12/17
to sage-devel
Hi. Thank you for the explanation.
You can add me to the list of people telling : export to stl is definitely good to have!

A
Reply all
Reply to author
Forward
0 new messages