Пример #1
0
    def surface(self):
        r"""
        Return the underlying translation surface without marked points.

        EXAMPLES::

            >>> from flatsurvey.surfaces import Ngon
            >>> Ngon((1, 1, 1)).surface()


        """
        S = self._surface()
        if self._eliminate_marked_points:
            from flatsurf.geometry.pyflatsurf_conversion import (
                from_pyflatsurf,
                to_pyflatsurf,
            )

            S = to_pyflatsurf(S)
            S.delaunay()
            S = from_pyflatsurf(S)
            S = S.erase_marked_points()
            S = to_pyflatsurf(S)
            S.delaunay()
            S = from_pyflatsurf(S)
        return S
def test_origami1():
    from sage.all import SymmetricGroup
    G = SymmetricGroup(2)
    r = u = G('(1,2)')
    O = translation_surfaces.origami(r, u)
    S = to_pyflatsurf(O)
    assert str(S) == "FlatTriangulationCombinatorial(vertices = (1, -3, 2, -1, 6, -5)(-2, 4, -6, 5, -4, 3), faces = (1, 2, 3)(-1, -5, -6)(-2, -3, -4)(4, 5, 6)) with vectors {1: (1, 1), 2: (-1, 0), 3: (0, -1), 4: (1, 1), 5: (-1, 0), 6: (0, -1)}"
def test_origami2():
    from sage.all import SymmetricGroup
    G = SymmetricGroup(3)
    r = G('(1,2,3)')
    u = G('(1,2)')
    O = translation_surfaces.origami(r, u)
    S = to_pyflatsurf(O)
    assert str(S) == "FlatTriangulationCombinatorial(vertices = (1, -3, 8, -7, 3, -2, 4, -6, 5, -4, 9, -8, 7, -9, 2, -1, 6, -5), faces = (1, 2, 3)(-1, -5, -6)(-2, -9, -4)(-3, -7, -8)(4, 5, 6)(7, 8, 9)) with vectors {1: (1, 1), 2: (-1, 0), 3: (0, -1), 4: (1, 1), 5: (-1, 0), 6: (0, -1), 7: (1, 1), 8: (-1, 0), 9: (0, -1)}"
Пример #4
0
def make_surface(surface_or_vertices, vectors = None):
    from collections.abc import Iterable
    if hasattr(surface_or_vertices, "__module__") and surface_or_vertices.__module__ == "flatsurf.geometry.translation_surface":
        if vectors is not None:
            raise ValueError("vectors must be none when creating a FlatTriangulation from a SageMath flatsurf surface")
        from flatsurf.geometry.pyflatsurf_conversion import to_pyflatsurf
        return to_pyflatsurf(surface_or_vertices)
    elif isinstance(surface_or_vertices, Iterable) and isinstance(vectors, Iterable):
        return make_FlatTriangulation(surface_or_vertices, vectors)
    else:
        raise TypeError("Unsupported parameters to make_surface()")
Пример #5
0
    def __init__(self, surface):
        if isinstance(surface, TranslationSurface):
            base_ring = surface.base_ring()
            from flatsurf.geometry.pyflatsurf_conversion import to_pyflatsurf
            self._surface = to_pyflatsurf(surface)
        else:
            from flatsurf.geometry.pyflatsurf_conversion import sage_base_ring
            base_ring, _ = sage_base_ring(surface)
            self._surface = surface

        # A model of the vector space R² in libflatsurf, e.g., to represent the
        # vector associated to a saddle connection.
        self.V2 = pyflatsurf.vector.Vectors(base_ring)

        # We construct a spanning set of edges, that is a subset of the
        # edges that form a basis of H_1(S, Sigma; Z)
        # It comes together with a projection matrix
        t, m = self._spanning_tree()
        assert set(t.keys()) == set(f[0] for f in self._faces())
        self.spanning_set = []
        v = set(t.values())
        for e in self._surface.edges():
            if e.positive() not in v and e.negative() not in v:
                self.spanning_set.append(e)
        self.d = len(self.spanning_set)
        assert 3*self.d - 3 == self._surface.size()
        assert m.rank() == self.d
        m = m.transpose()
        # projection matrix from Z^E to H_1(S, Sigma; Z) in the basis
        # of spanning edges
        self.proj = matrix(ZZ, [r for r in m.rows() if not r.is_zero()])

        self.Omega = self._intersection_matrix(t, self.spanning_set)

        self.V = FreeModule(self.V2.base_ring(), self.d)
        self.H = matrix(self.V2.base_ring(), self.d, 2)
        for i in range(self.d):
            s = self._surface.fromHalfEdge(self.spanning_set[i].positive())
            self.H[i] = self.V2._isomorphic_vector_space(self.V2(s))
        self.Hdual = self.Omega * self.H

        # Note that we don't use Sage vector spaces because they are usually
        # way too slow (in particular we avoid calling .echelonize())
        self._U = matrix(self.V2._algebraic_ring(), self.d)
        
        if self._U.base_ring() is not QQ:
            from sage.all import next_prime
            self._good_prime = self._U.base_ring().ideal(next_prime(2**30)).factor()[0][0]
            self._Ubar = matrix(self._good_prime.residue_field(), self.d)

        self._U_rank = 0

        self.update_tangent_space_from_vector(self.H.transpose()[0])
        self.update_tangent_space_from_vector(self.H.transpose()[1])
Пример #6
0
    def to_yaml(cls, representer, self):
        from flatsurf.geometry.pyflatsurf_conversion import to_pyflatsurf

        surface = to_pyflatsurf(self.surface())
        representer.add_representer(type(surface), type(surface).to_yaml)

        return representer.represent_data({
            "angles": self.angles,
            "length": self.length,
            "polygon": self.polygon(),
            "translation_cover": self.surface(),
            "surface": surface,
        })
def test_ward3():
    W3 = translation_surfaces.ward(3)
    X3 = to_pyflatsurf(W3)

    W17 = translation_surfaces.ward(17)
    X17 = to_pyflatsurf(W17)
def test_arnoux_yoccoz(g):
    A = translation_surfaces.arnoux_yoccoz(g)
    B = to_pyflatsurf(A)
def test_regular_n_gons(n):
    S = translation_surfaces.veech_double_n_gon(n)
    T = to_pyflatsurf(S)
 def __init__(self, surface):
     from flatsurf.geometry.pyflatsurf_conversion import to_pyflatsurf
     triangulation = to_pyflatsurf(surface)
     VueFlatsurfWidget.__init__(self, triangulation)