# This file was *autogenerated* from the file scripts/render.sage from sage.all_cmdline import * # import sage library _sage_const_3 = Integer(3); _sage_const_1 = Integer(1); _sage_const_0 = Integer(0); _sage_const_0p2 = RealNumber('0.2'); _sage_const_1000 = Integer(1000); _sage_const_1en10 = RealNumber('1e-10'); _sage_const_30 = Integer(30); _sage_const_20 = Integer(20) import sys import math M=_sage_const_3 ZERO=_sage_const_1en10 def angle_cmp(v): return math.atan2(v[_sage_const_0 ], v[_sage_const_1 ]) for fname in sys.argv[_sage_const_1 :]: load(fname) nrays = len(pi) frat = f.apply_map(lambda x : x.nearby_rational(max_denominator=_sage_const_1000 )) vertices = [(f+R[i]/pi[i]).apply_map(lambda x: x.nearby_rational(max_denominator=_sage_const_1000 )) for i in range(nrays)] poly = Polyhedron(vertices=vertices) print "Writing %s.tex..." % fname texfile = open("%s.tex" % fname, "w") texfile.write("\\draw[fill,fill opacity=0.1] ") for v in sorted(poly.vertices(), key=angle_cmp): texfile.write("(%s, %s) -- " % (v[_sage_const_0 ], v[_sage_const_1 ])) texfile.write("cycle;\n") #texfile.write("\\draw (%s, %s) circle [radius=1.5pt];\n" % (frat[0], frat[1])) for v in vertices: texfile.write("\\draw[dashed] (%s,%s) -- (%s,%s);\n" % (frat[_sage_const_0 ], frat[_sage_const_1 ], v[_sage_const_0 ], v[_sage_const_1 ])) texfile.close() print "Writing %s.png..." % fname p0 = sum([arrow(f, f + R[i] / pi[i], color='blue') for i in range(nrays)]) pf = list_plot([f], color='red', pointsize=_sage_const_30 , zorder=-_sage_const_1 ) p1 = poly.plot(color='blue', alpha=_sage_const_0p2 ) p3 = list_plot( [(x,y) for x in range(-M,M+_sage_const_1 ) for y in range(-M,M+_sage_const_1 )], color='black', figsize=_sage_const_20 , pointsize=_sage_const_30 , zorder=_sage_const_1 ) output = "%s.png" % fname save(p0+pf+p3+p1, output, xmin=-M, ymin=-M, xmax=M, ymax=M)