I want to get a random point in a circle.
What parameters make up a point in a circle?
Radius and angle can be one, so let's randomise those.
This is something that's done a lot in game development.
I want to get a random point in a circle.
What parameters make up a point in a circle?
Radius and angle can be one, so let's randomise those.
This is something that's done a lot in game development.
Btw, here's a way to sample a uniform random point on the edge of a circle without trigonometric functions:
Sample x and y coordinates from a standard normal distribution. Then project the result on the circle, by normalising the distance.
(You can approximate normal distributions fairly easily. Or your favourite computing environment might have specialised optimized machinery built-in.)
I wonder if that's uniform...
I expect that you would have more points mapped to the corners.
This says otherwise
var a = Math.max(Math.random(), Math.random());
var b = Math.sqrt(Math.random());I came across that one in the other direction, when trying to work out how to make weighted rendezvous hashing work. See https://en.wikipedia.org/wiki/Rendezvous_hashing