quote:
Original post by Null and Void
ZealousElixir, your version only finds a point on the outside of the circle (not any point within the circle).
This is true. My bad. See below for the new version.
quote:
Also, yours will be less random due to your use of the low order bits (you're using modulo instead of division to cap the random value).
Bullcrap.
quote:
Beer Hunter, what I mean was: what if every x returned is 0 and every 0 returned is 0? The point 0,0 isn't going to be in the circle. Well, that isn't very likely, I know. But, there's someodd other points that aren't in the circle either. So, what if every other value is rejected because of that? The algorithm could take a very long time to finally pick a point inside the circle if you're unlucky. If you're really unlucky, the algorithm could never complete!
With millons of these calls happening per second, the odds of that are not even worth considering. Granted, the method he's suggesting is freaking slow.
Here's my way:
|
Tada.
Later,
ZE.
Edited by - ZealousElixir on December 27, 2001 10:27:43 PM