flatsurf / sage-flatsurf

Flat surfaces in Sage
https://flatsurf.github.io/sage-flatsurf/
GNU General Public License v2.0
10 stars 10 forks source link

Implement subdivide() for surfaces and polygons #207

Closed saraedum closed 1 year ago

saraedum commented 1 year ago

This adds a subdivide() to Polygon, Surface and SimilaritySurface that subdivides polygons into triangles centered at the centroid of the polygons.

sage: from flatsurf import translation_surfaces
sage: S = translation_surfaces.veech_double_n_gon(5)
sage: S.subdivide().plot()

image

sage: S.subdivide().subdivide().subdivide().subdivide().plot(edge_labels=None, polygon_labels=False)

image

sage: S.subdivide().subdivide().subdivide().subdivide().delaunay_triangulation().plot(edge_labels=None, polygon_labels=False)

image

We can also subdivide edges first which is probably what we'll need for the harmonic differentials code since the Delaunay triangulation looks a bit better to me:

sage: S.subdivide_edges().subdivide().plot()  # unfortunate layout

image

sage: S.subdivide().subdivide_edges(3).subdivide().subdivide_edges().subdivide().plot(edge_labels=None, polygon_labels=False)

image

sage: S.subdivide().subdivide_edges(3).subdivide().subdivide_edges().subdivide().delaunay_triangulation().plot(edge_labels=None, polygon_labels=False)

image

This is maybe a good subdivision of the octagon for our purposes:

sage: S = translation_surfaces.regular_octagon()
sage: S.subdivide().subdivide_edges(3).subdivide().delaunay_triangulation().plot(edge_labels=False, polygon_labels=False)

image


Checklist

saraedum commented 1 year ago

@videlec this is the simplest thing, just subdividing the polygon but keeping all the original edges. I guess it's better for the purpose of the harmonic differentials to also split each of the existing edges into two new edges? (Implemented, now.)

saraedum commented 1 year ago

Do we have any similarity surface gluings where subdivide_edges() cannot be implemented by just splitting each edge into equal parts?

saraedum commented 1 year ago

@videlec, does this look good to you now?

github-actions[bot] commented 1 year ago

Documentation preview for this PR is ready! :tada: Built with commit: ec8780c5f88d4215d360c9a813a319508b67c12e