![]() ![]() The triangles are just there for visualization. Rtri = tri.Triangulation(rx, ry, iangles) # distorted gridĪx.plot(cx, cy,'k-', alpha=.2) # circle line Ry = y + np.random.uniform(low=-g/n, high=g/n, size=y.shape) Rx = x + np.random.uniform(low=-g/n, high=g/n, size=x.shape) Triang = tri.Triangulation(x, y) # create triangluar grid Ii = np.argwhere(s_x**2 + s_y**2 <= 1).ravel() # mask off unwanted points Xx, yy = np.meshgrid(tt, tt) # create unit square grid Theta = np.random.uniform(low=0, high=2*np.pi, size=n) # angleĪx.plot(cx, cy,'-', alpha=.5) # draw unit circle lineĪlternatively, you also could create a regular grid and distort it randomly: import numpy as np R = np.random.uniform(low=0, high=1, size=n) # radius ![]() So my question is rather broad: is there a better way to do this? My method is ok for now, but my gut says that there is a better way to generate such a field of points.Īn illustration of the output is graphed below, one with a high closeness criteria, and another with a 'lowest found' closeness criteria (what I want).Ī simple solution based on Disk Point Picking from MathWorld: import numpy as np At some point, the script can not finish, and I just use the points of the last successful iteration. In order to get the most even point density, what I do is basically iteratively run this script using another script, with the 'closeness' criteria reduced for each successive iteration. Outfile_name = "pt_locs_x_lo_"+str(pts_per_disk)+"_pts.txt" While len(pts_in_disk) min_closeness_criteria: Min_closeness_criteria = disk_diam/closeness_criteriaĭisk_center = My current method is to place a point, check if it's inside the disk, and then check if it is also far enough away from all other points already kept. I want the points to be somewhat random, but still have a more or less regular density over the disk. I have an application that requires a disk populated with 'n' points in a quasi-random fashion. ![]()
0 Comments
Leave a Reply. |