Generating a random point within a circle (uniformly)
For a circle of radius
R you do:
double a = rand() * 2 * PI double r = R * sqrt(rand()) double x = r * cos(a) double y = r * sin(a)
rand() gives a uniformly random number between 0 and 1.
Here are 4000 points within a radius of 100 pixels generated with the above method.