I need to plot n number of points inside a circle of say radius R, randomly. When I try to do it with a random theta, and random distance from the center of the circle, points are concentrated towards the center of the circle and rightfully so. Is there a way to have them spread randomly over the circle as shown below in the image?
desired output:
Current output:
below is the code in D3.js for the current output:
while(count){ (count is the number of points to be plotted inside the circle)
var randAngle = Math.random()*Math.PI*2;
var randRadius = Math.random()*radius; (radius is the radius of the circle in which I want to plot)
var randX = cx + randRadius * Math.cos(randAngle);
var randY = cy + randRadius * Math.sin(randAngle);
parent_group_dns.append('rect')
.attr('x', randX)
.attr('y', randY)
.attr('width', 1.5)
.attr('height', 1.5)
.attr('fill', 'white')
count--;
}
is there a way to distribute points not by theta but just by distances?