ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 29 Mar 2013 07:26:31 +0100Translating a polygon into a fundamental domainhttps://ask.sagemath.org/question/9946/translating-a-polygon-into-a-fundamental-domain/Hello.
I have a polygon (defined, say, via polygon()) that I'm thinking of as filled in with some color. I'd like to understand its image on the quotient of $\mathbb{R}^2$ mod $\mathbb{Z}^2$ by seeing this image in a fundamental domain like the unit square with corners (0,0), (1,0), (0,1), (1,1).
Put differently, I want to translate (by a lattice point) each point in and on the polygon into this square and see what the result looks like.
Is there a reasonable way to do this in SAGE?Wed, 27 Mar 2013 15:48:53 +0100https://ask.sagemath.org/question/9946/translating-a-polygon-into-a-fundamental-domain/Answer by vdelecroix for <p>Hello.</p>
<p>I have a polygon (defined, say, via polygon()) that I'm thinking of as filled in with some color. I'd like to understand its image on the quotient of $\mathbb{R}^2$ mod $\mathbb{Z}^2$ by seeing this image in a fundamental domain like the unit square with corners (0,0), (1,0), (0,1), (1,1).</p>
<p>Put differently, I want to translate (by a lattice point) each point in and on the polygon into this square and see what the result looks like.</p>
<p>Is there a reasonable way to do this in SAGE?</p>
https://ask.sagemath.org/question/9946/translating-a-polygon-into-a-fundamental-domain/?answer=14702#post-id-14702Hi,
polygon is just a function for plotting. In order to be able to solve your problem you should use Polyhedron as in
sage: P = Polyhedron(vertices=[(0,0),(1.3,2.2),(0.7,1)])
sage: P.plot()
![image description](/upfiles/13645562487499463.png)
Then you compute a bounding box for your polyhderon
sage: xmin = min(x for x,y in P.vertices_list())
sage: xmax = max(x for x,y in P.vertices_list())
sage: ymin = min(y for x,y in P.vertices_list())
sage: ymax = max(y for x,y in P.vertices_list())
And for each square fundamental domain within your bounding box you compute the intersection of P with the square and store the translates:
sage: L = []
sage: for i in xrange(xmin,xmax+1):
... for j in xrange(ymin,ymax+1):
... K = P.intersection(Polyhedron(vertices=[(i,j),(i+1,j),(i+1,j+1),(i,j+1)]))
... if K.dim() == 2:
... L.append(K.translation((-i,-j)))
Then you can plot each pieces into a fundamental domain:
sage: n = len(L)
sage: colors = rainbow(n,'rgbtuple')
sage: sum((L[i].plot(color=colors[i]) for i in xrange(n)), Graphics())
![image description](/upfiles/13645563527880477.png)
VincentFri, 29 Mar 2013 07:26:31 +0100https://ask.sagemath.org/question/9946/translating-a-polygon-into-a-fundamental-domain/?answer=14702#post-id-14702