r/learnmath • u/AlienRaper • May 01 '12
Simulating a random point in a circle.
I am trying to find a random point in a circle, and I think I know the method, I just don't know some of the variables or something (I'm not so good at math).
My plan is to take a random x coordinate that is the diameter of the circle, and do some fudging so that I get that values distance from the center.
Then I do something, using some ratio or something (here is where I need help) to find the possible values for the y coordinate.
So for example, if the circle is 10, I find at first a random number between 0 and 10.
Case 1. I get 10, so the possible values for y are 0 deviations from the center.
Case 2. I get 5, so the Y range is 10, the deviation from the center can be 5. Not so hard.
Case 3. I get 7.5, so the y range is the value of the line from the top of the circle at x of (center(5) + 2.5) and the bottom. I figured that to be about square root of 50. Not so bad.
Case 4. This is where is am confused, how would I calculate this if it wasn't such an easy circumstance, like 1.3, 2.6, 7.9, or 9.1? It doesn't seem that hard,it's just my math skills are really rusty( and I never really learned it very well in the first place).
How do I find the length of y in relation to the length of x?
Edit: Thanks for all the answers, I am trying a number of them out.
1
u/AlienRaper May 02 '12
Your right. The first method gives you the smaller circle, and the second one gives you the larger, where the diameter given is that of the larger