# Last edited on 2021-07-31 15:03:58 by jstolfi def sampling_2d_grid_choose(xmin,xmax,nx, ymin,ymax,ny): # Generates a uniform grid of sampling points in the rectangle # {D = {xmin _ xmax} × [ymin _ ymax]}, with {nx} points in {v} # and {ny} in {y}. # # Specifically, divides {D} into a grid of {nx} by {ny} # rectangles and puts a semapling point in the center of each rectangle. ns = nx*ny; # Total number of samples. s = []; # The sampling points. for ix in range(nx): x = 2*(ix + 0.5)/nx - 1; for iy in range(ny): y = 2*(iy + 0.5)/ny - 1; s.append((x,y)); return s # ----------------------------------------------------------------------