I had looked these topics but they don't resolve my problem:
Uniformly distribute x points inside a circle
Generate a random point within a circle (uniformly)
My problem is:
What I have:
Any algorithm to randomly distribute n of points between 2 circles?
Thank you very much!
p/s: I am familiar with C#, C family and pseudo code.
Update This is my attempt. Let's say the center is (0, 0) (for easier looking)
Vector2[] points = new Vector2[n];
for (int i = 0; i < n; ++i)
{
do
{
points[n] = new Vector2(Random.Range(0f, r2), Random.Range(0f, r2));
} while (points[n].magnitude >= r2 || points[n].magnitude <= r1);
}
I had looked these topics but they don't resolve my problem
It doesn't make sense, the answer in the second question should answer this question too. In the Konrad's comment he also provided an algorithm to generate points on a ring.
r1s = r1 * r1
r2s = r2 * r2
r = sqrt(random() * (r2s - r1s) + r1s)
theta = random() * 2 * PI
x = centerX + r * cos(theta)
y = centerY + r * sin(theta)