Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MutableOrientedHyperbolicSurface #243

Draft
wants to merge 71 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
dc818e3
Add MutableOrientedHyperbolicSurface
saraedum Jul 5, 2023
874e6ef
Merge remote-tracking branch 'origin/master' into hyperbolic_surface
saraedum Jul 7, 2023
ceed905
Add basics for building hyperbolic surfaces
saraedum Jul 7, 2023
a907243
Add doctest output
saraedum Jul 7, 2023
27fe717
Make vertices() of hyperbolic polygons work
saraedum Jul 7, 2023
0b54357
Add cusps() for hyperbolic surfaces
saraedum Jul 7, 2023
ed66260
Document hyperbolic surface category
saraedum Jul 10, 2023
a88f522
Implement plotting for hyperbolic surfaces
saraedum Jul 10, 2023
433999d
Normalize point coordinates
saraedum Jul 18, 2023
be09c50
Revert "Normalize point coordinates"
saraedum Jul 18, 2023
07f0342
Fix some mutability issues to make hyperbolic surfaces work
saraedum Jul 18, 2023
5adb70f
Deprecate angles() in favor of angle()
saraedum Jul 19, 2023
ee12150
Improve printing of hyperbolic surfaces
saraedum Jul 19, 2023
046bfe7
Fix computation of orbifold points
saraedum Jul 20, 2023
d38abe8
Add rudimentary support for orbifold points
saraedum Jul 20, 2023
828f0a4
Unify isometries and similarities acting on edges of polygons
saraedum Jul 20, 2023
6e1db82
Improve doctesting of hyperbolic surfaces
saraedum Jul 20, 2023
c0e8c50
Fix printing of polygons making up surfaces
saraedum Jul 20, 2023
cf07ac1
Remove duplicated doctests
saraedum Jul 21, 2023
7bda80f
Document angle() of cone surfaces
saraedum Jul 21, 2023
18db2e7
Document is_right() and is_isosceles()
saraedum Jul 21, 2023
978ac18
Document changes in get_edge()
saraedum Jul 21, 2023
6235123
Improve error message
saraedum Jul 21, 2023
a15e020
Document angle() for half translation surfaces
saraedum Jul 21, 2023
16792c7
Improve printing of hyperbolic surfaces with boundary
saraedum Jul 27, 2023
64821ff
Fix midpoint containment computations
saraedum Jul 27, 2023
ca17da9
Fix infinite recursion in printing of midpoints
saraedum Jul 27, 2023
55e9c40
Improve printing of hyperbolic midpoints
saraedum Jul 27, 2023
3f4c82e
Allow gluing of half-infinite hyperbolic edges
saraedum Jul 27, 2023
0690cca
Fix & document implementation of cusps and orbifold points
saraedum Jul 27, 2023
69ecf78
Add angle() method to surface points
saraedum Jul 27, 2023
62ff3a8
Document ElementMethods container
saraedum Jul 27, 2023
94d1401
Document new methods for hyperbolic isometry surfaces
saraedum Jul 27, 2023
ea18bc0
Implement adjacencies() for polygons
saraedum Jul 30, 2023
1f62768
Improve printing of hyperbolic segments
saraedum Jul 31, 2023
715c8a6
Fix midpoint computation when defined over the base ring
saraedum Jul 31, 2023
06859ee
Fix doctests
saraedum Aug 17, 2023
4e17413
Fix spacing
saraedum Aug 17, 2023
1d11bef
Deduplicate plot() function of surfaces
saraedum Aug 17, 2023
b3b4baf
Add news
saraedum Aug 23, 2023
d8efcb4
Remove unused imports
saraedum Aug 24, 2023
4019ab1
Fix polygon plot in hyperbolic surfaces
saraedum Aug 24, 2023
3c96335
Refer to notebook of examples for plotting documentation
saraedum Aug 24, 2023
40cfe14
Improve fill of polygons
saraedum Aug 25, 2023
5de31ec
Implement layout(algorithm="trajectory")
saraedum Sep 12, 2023
5340849
Merge remote-tracking branch 'origin/master' into hyperbolic_surface
saraedum Sep 12, 2023
fd01b41
Turn longstanding TODOs into NOTEs
saraedum Sep 17, 2023
f7bd8f6
Turn TODOs into NotImplementedErrors for polygons
saraedum Sep 17, 2023
3b514f7
Drop TODO
saraedum Sep 17, 2023
c945e4e
is_right_triangle() for hyperbolic triangles
saraedum Sep 17, 2023
28c3dd4
Implement is_isosceles_triangle() for hyperbolic triangles
saraedum Sep 17, 2023
26f3dcd
Implement is_equilateral() for hyperbolic polygons
saraedum Sep 17, 2023
5753cc7
Implement is_equiangular() for hyperbolic polygons
saraedum Sep 17, 2023
f291724
Fix doctest
saraedum Sep 17, 2023
f7e07cb
Clarify isometry condition
saraedum Sep 17, 2023
8405663
Deduplicate midpoint computations
saraedum Sep 17, 2023
7d31e4f
Fix handling of unoriented geodesics and segments
saraedum Sep 18, 2023
5da9f28
Deprecate coordinates() which does not easily make sense in the hyper…
saraedum Sep 18, 2023
1b0c62c
Turn longstanding TODO into a Note
saraedum Sep 18, 2023
3bfa0ef
Simplify alignment logic
saraedum Sep 18, 2023
39d4ac7
Mark TODOs as resolved
saraedum Sep 18, 2023
66ab592
Resolve TODO
saraedum Sep 18, 2023
46cb86a
Resolve TODO
saraedum Sep 18, 2023
b5620d8
Resolve TODO
saraedum Sep 18, 2023
e153135
Remove incorrect hash function
saraedum Sep 18, 2023
1313bda
Fix representative() implementation
saraedum Sep 18, 2023
e1f7af2
Fix deprecation warnings
saraedum Sep 18, 2023
f482511
Remove resolved TODO
saraedum Sep 18, 2023
ec3e802
Turn an old TODO into a Note
saraedum Sep 18, 2023
79c0be5
Remove leftovers from the old graphical surface implementation
saraedum Sep 18, 2023
8ef5c10
Implement most of hyperbolic surface plotting
saraedum Sep 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/examples/graphics_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ kernelspec:
name: sagemath
---

# TODO: Update these examples and make sure that all parameters understood by graphical surfaces are documented here.

# Graphics Configuration

## Rearranging Polygons
Expand Down
8 changes: 4 additions & 4 deletions doc/examples/straight_line_flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ TB = s.tangent_bundle()
jupyter:
outputs_hidden: false
---
baricenter = sum(s.polygon(0).vertices()) / 5
barycenter = sum(s.polygon(0).vertices()) / 5
```

Define the tangent vector based at the baricenter of polygon 0 aimed downward.
Define the tangent vector based at the barycenter of polygon 0 aimed downward.

```{code-cell}
---
jupyter:
outputs_hidden: true
---
v = TB(0, baricenter, (0, -1))
v = TB(0, barycenter, (0, -1))
```

Convert to a straight-line trajectory. Trajectories are unions of segments in polygons.
Expand Down Expand Up @@ -117,7 +117,7 @@ Lets do it again but in the slope one direction.
jupyter:
outputs_hidden: false
---
v = TB(0, baricenter, (1, 1))
v = TB(0, barycenter, (1, 1))
```

```{code-cell}
Expand Down
39 changes: 39 additions & 0 deletions doc/news/hyperbolic_surface.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
**Added:**

* Added ``is_right_triangle()`` and ``is_isosceles_triangle()`` to polygons.

* Added categories for hyperbolic surfaces, namely ``HyperbolicPolygonalSurfaces`` and ``HyperbolicIsometrySurfaces``.

* Added ``angle()`` method to points on a surface to return the total angle at a point.

* Added ``adjacencies()`` method to polygons that reports the edges adjacent to the vertices in order. This is necessary for hyperbolic polygons of infinite area where some vertices might not be adjacent to two edges.

**Changed:**

* Changed surface plotting quite a bit to make the same code work for hyperbolic surfaces and similarity surfaces. Edge labels can now only be configured differently for adjacent edges, non-adjacent edges, self-glued edges, and boundary edges. The new defaults there should make it much easier to interactively build a surface.

**Fixed:**

* Fixed merging of hyperbolic sets of vertices.

* Fixed ``vertices()`` of hyperbolic polygons with marked vertices in some edge cases.

* Fixed ``angle(numerical=True)`` of polygons which are now consistently returned as elements in RR.

* Fixed implementation of ``an_element()`` for testing to also create points on non-similarity surfaces.

* Fixed vectors returned by methods. The returned vectors are now immutable in more places.

* Fixed computation of pole of hyperbolic geodesics so it works without extending the base ring.

* Fixed handling of points at vertices of surfaces with boundary.

* Fixed complicated printing of hyperbolic segments. Now, segments are printed as ``start → end`` instead of giving the intersection of the half planes that define the segment.

**Deprecated:**

* Deprecated ``angles()`` method of surfaces.

**Removed:**

* Removed ``plot_polygon()`` on surfaces. All plotting is now in graphical surfaces. (This function can largely be emulated by hiding all but one polygon in a graphical surface before plotting.)
2 changes: 1 addition & 1 deletion flatsurf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
translation_surfaces,
)

from flatsurf.geometry.surface import MutableOrientedSimilaritySurface
from flatsurf.geometry.surface import MutableOrientedSimilaritySurface, MutableOrientedHyperbolicSurface

from flatsurf.geometry.gl2r_orbit_closure import GL2ROrbitClosure

Expand Down
6 changes: 5 additions & 1 deletion flatsurf/geometry/categories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
sage: TranslationSurfaces.FiniteType.WithoutBoundary.ParentMethods.stratum(S)
Traceback (most recent call last):
...
AttributeError: ... no attribute 'angles'
AttributeError: ... no attribute 'angle'

So this approach is quite brittle and might need a mix with the above to work::

Expand Down Expand Up @@ -171,7 +171,11 @@
from flatsurf.geometry.categories.euclidean_polygonal_surfaces import (
EuclideanPolygonalSurfaces,
)
from flatsurf.geometry.categories.hyperbolic_polygonal_surfaces import (
HyperbolicPolygonalSurfaces,
)
from flatsurf.geometry.categories.similarity_surfaces import SimilaritySurfaces
from flatsurf.geometry.categories.hyperbolic_isometry_surfaces import HyperbolicIsometrySurfaces
from flatsurf.geometry.categories.cone_surfaces import ConeSurfaces
from flatsurf.geometry.categories.dilation_surfaces import DilationSurfaces
from flatsurf.geometry.categories.half_translation_surfaces import (
Expand Down
74 changes: 73 additions & 1 deletion flatsurf/geometry/categories/cone_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,72 @@ def _is_cone_surface(surface, limit=None):

return True

class ElementMethods:
r"""
Provides methods available to all points on cone surfaces.

If you want to add methods to such points, you most likely want to put
them here.
"""

def angle(self, numerical=False):
r"""
Return the total angle at this ``point`` in multiples of 2π.

INPUT:

- ``numerical`` -- a boolean (default: ``False``); whether to
return a numerical approximation or the exact angle.

EXAMPLES::

sage: from flatsurf import polygons, similarity_surfaces
sage: T = polygons.triangle(3, 4, 5)
sage: S = similarity_surfaces.billiard(T)
sage: [v.angle() for v in S.vertices()]
[1/4, 5/12, 1/3]

sage: [v.angle(numerical=True) for v in S.vertices()]
[0.250000000000000, 0.416666666666667, 0.333333333333333]

At an interior point of a polygon the total angle is 2π::

sage: p = S(0, S.polygon(0).centroid())
sage: p.angle()
1

"""
surface = self.parent()

if numerical:
from sage.all import RR
angle = RR(0)
else:
from sage.all import ZZ
angle = ZZ(0)

if not self.is_vertex():
label, coordinates = self.representative()
position = surface.polygon(label).get_point_position(coordinates)
if position.is_in_interior():
angle += 1
elif surface.opposite_edge(label, position.get_edge()) == (label, position.get_edge()):
# point on self-glued edge
from sage.all import ZZ
angle += ZZ(1) / 2
else:
# point on non-self-glued edge
angle += 1

return angle

for label, edge in self.edges():
angle += surface.polygon(label).angle(edge, numerical=numerical)
if surface.opposite_edge(label, edge) is None:
raise ValueError("vertex at boundary does not have a total angle")

return angle

class FiniteType(SurfaceCategoryWithAxiom):
r"""
The category of cone surfaces built from finitely many polygons.
Expand Down Expand Up @@ -326,6 +392,9 @@ def angles(self, numerical=False, return_adjacent_edges=False):
sage: T = polygons.triangle(3, 4, 5)
sage: S = similarity_surfaces.billiard(T)
sage: S.angles()
doctest:warning
...
UserWarning: angles() has been deprecated and will be removed in a future version of sage-flatsurf; use [vertex.angle() for vertex in self.vertices()] instead; if you need the adjacent edges use vertex.edges().
[1/3, 1/4, 5/12]
sage: S.angles(numerical=True) # abs tol 1e-14
[0.333333333333333, 0.250000000000000, 0.416666666666667]
Expand All @@ -334,6 +403,9 @@ def angles(self, numerical=False, return_adjacent_edges=False):
[(1/3, [(0, 1), (1, 2)]), (1/4, [(0, 0), (1, 0)]), (5/12, [(1, 1), (0, 2)])]

"""
import warnings
warnings.warn("angles() has been deprecated and will be removed in a future version of sage-flatsurf; use [vertex.angle() for vertex in self.vertices()] instead; if you need the adjacent edges use vertex.edges().")

if not numerical and any(
not p.is_rational() for p in self.polygons()
):
Expand Down Expand Up @@ -440,6 +512,6 @@ def _test_genus(self, **options):

tester.assertAlmostEqual(
self.genus(),
sum(a - 1 for a in self.angles(numerical=True)) / 2.0
float(sum(v.angle(numerical=True) - 1 for v in self.vertices()) / 2.0)
+ 1,
)
Loading
Loading