verty = [10., 125., 90., 10.] q = Polygon([ Point(20., 10.), Point(50., 125.), Point(125., 90.), Point(150., 10.) ]) output = open("inside_short.dat", "w") start = time() for i in range(160): for j in range(135): output.write("{0:d}\t{1:d}\t{2:d}\t{3:d}\n".format( i, j, pnpoly(nvert, vertx, verty, i, j), q.contains(Point(i, j)))) output.close() print "short" print time() - start plot_data = open("inside_long.dat", "w") start2 = time() for i in range(160): for j in range(135): plot_data.write("{0:d}\t{1:d}\t{2:d}\n".format( i, j, q.contains(Point(i, j)))) plot_data.close() print "long" print time() - start2 # Plot ------------------------------------------------------------------
if __name__ == "__main__": nvert = 4 vertx = [20., 50., 125., 150.] verty = [10., 125., 90., 10.] q = Polygon([Point(20., 10.), Point(50., 125.), Point(125., 90.), Point(150., 10.)]) output = open("inside_short.dat", "w") start = time() for i in range(160): for j in range(135): output.write("{0:d}\t{1:d}\t{2:d}\t{3:d}\n".format(i, j, pnpoly(nvert, vertx, verty, i, j), q.contains(Point(i, j)))) output.close() print "short" print time() - start plot_data = open("inside_long.dat", "w") start2 = time() for i in range(160): for j in range(135): plot_data.write("{0:d}\t{1:d}\t{2:d}\n".format(i, j, q.contains(Point(i, j)))) plot_data.close() print "long" print time() - start2 # Plot ------------------------------------------------------------------ verts = [(20, 10),
# print pnpoly(4, [0., 0., 100., 100.], [0., 100., 100., 0.], 0., 10.) if __name__ == "__main__": nvert = 4 vertx = [20.0, 50.0, 125.0, 150.0] verty = [10.0, 125.0, 90.0, 10.0] q = Polygon([Point(20.0, 10.0), Point(50.0, 125.0), Point(125.0, 90.0), Point(150.0, 10.0)]) output = open("inside_short.dat", "w") start = time() for i in range(160): for j in range(135): output.write( "{0:d}\t{1:d}\t{2:d}\t{3:d}\n".format(i, j, pnpoly(nvert, vertx, verty, i, j), q.contains(Point(i, j))) ) output.close() print "short" print time() - start # plot_data = open("inside_long.dat", "w") # start2 = time() # for i in range(160): # for j in range(135): # plot_data.write("{0:d}\t{1:d}\t{2:d}\n".format(i, j, q.contains(Point(i, j)))) # plot_data.close() # print "long" # print time() - start2 # Plot ------------------------------------------------------------------