#!/usr/bin/env python
# Generates a set of points which are evenly spaced
# Not very efficient, but simple. Should be good for
# around 10,000 points or so.
import random, pickle
random_list = [[random.uniform(-2500,2500), random.uniform(-2500,2500)]]
#This is the radius -- the minimum allowable distance, squared
#I keep it squared to avoid a computationally expensive square root operation.
radius = 3600
def distance_squared(point1, point2):
x = point1[0] - point2[0]
y = point1[1] - point2[1]
return x**2 + y**2
for i in range(500000):
point = [random.uniform(-2500,2500), random.uniform(-2500,2500)]
for j in random_list:
if distance_squared(point, j) < radius:
break
else:
random_list.append(point)
pickle.dump(random_list, open("poisson_disc_list5.p","wb"))