FlatSurf Demo 2
system:sage


<h2>Constructing the square:</h2>

{{{id=9|
from flatsurf.geometry.polygon import Polygons
///
}}}

<p>The following is the parent for polygons with coordinates in the field K.</p>
<p>Remarks:</p>
<ul>
<li>The first vertex of our polygons is always the origin.</li>
<li>All our polygons are convex.&nbsp;</li>
</ul>

<p>To construct a polygon, use the parent to build the parent. Passing a list of edge vectors will produce the polygon. The edge vectors must sum to zero.</p>

{{{id=5|
square = Polygons(QQ)([(1,0),
(0, 1),
(-1,0),
(0, -1)
])

print(square)
///
Polygon: (0, 0), (1, 0), (1, 1), (0, 1)
}}}

{{{id=79|
square.plot()
///
}}}

<p><img src="file:///home/pat/active/talks/2016/Oaxaca-SAGE_Days/square.svg" alt="Picture of the square with edge labels." /></p>
<h2>Defining the staircase</h2>

{{{id=47|
from flatsurf.geometry.surface import Surface
from flatsurf import *
///
}}}

{{{id=19|
class StaircaseSurface(Surface):
    r"""The Staircase surface."""
    
    def __init__(self):
        # Store the square:
        self._square = Polygons(QQ)([(1,0), (0, 1), (-1,0), (0, -1)])
        # The surface will be defined by polygons with vertices with rational coordinates,
        # will have a base label as zero, and will be infinite
        Surface.__init__(self, QQ, 0, finite=False)        

    def polygon(self, lab):
        return self._square
    
    def opposite_edge(self, p, e):
        if e==0 or e==2:
            if p%2==0:
               return p-1, (e+2)%4
            else:
                return p+1, (e+2)%4
        else:
            if p%2==0:
                return p+1, (e+2)%4
            else:
                return p-1, (e+2)%4
///
}}}

<p>We think of this surface as a TranslationSurface.</p>

{{{id=48|
s = TranslationSurface(StaircaseSurface())
///
}}}

{{{id=24|
gs = s.graphical_surface()
///
}}}

{{{id=49|
gs.plot()
///
}}}

{{{id=52|
gs.make_adjacent_and_visible(0,1)
gs.make_adjacent_and_visible(1,2)
///
}}}

{{{id=58|
gs.plot()
///
}}}

{{{id=50|
gs = s.graphical_surface()
for i in range(3):
    gs.make_adjacent_and_visible(2*i,1)
    gs.make_adjacent_and_visible(2*i+1,2)
///
}}}

{{{id=51|
gs.plot()
///
}}}

<h2>Straight-Line Flow</h2>

{{{id=63|
from flatsurf.geometry.tangent_bundle import SimilaritySurfaceTangentBundle
///
}}}

<p>We will flow in a direction of slope given by the golden mean, phi. This builds a number field and defines phi.</p>

{{{id=75|
K.<phi> = NumberField(x**2-x-1, embedding=1.6)
///
}}}

{{{id=65|
v=s.tangent_vector(4,(0,0),(1,phi),ring=K)
///
}}}

{{{id=67|
traj=v.straight_line_trajectory()
traj.flow(1000)
///
}}}

{{{id=68|
from flatsurf.graphical.straight_line_trajectory import GraphicalStraightLineTrajectory
///
}}}

{{{id=69|
gtraj = GraphicalStraightLineTrajectory(gs,traj)
///
}}}

{{{id=71|
gs.plot()+gtraj.plot()
///
}}}

{{{id=74|
K.<rt2> = NumberField(x**2 - 2, embedding=1.4)
v=s.tangent_vector(4,(0,0),(1,rt2),ring=K)
///
}}}

{{{id=76|
traj = v.straight_line_trajectory()
traj.flow(1000)
///
}}}

{{{id=77|
gtraj = GraphicalStraightLineTrajectory(gs,traj)
///
}}}

{{{id=78|
gs.plot()+gtraj.plot()
///
}}}