How do i randomize a position on a sphere? Using a random number between 0 and 360 for longitude and a number between -90 to 90 for latitude would make it more probable to get closer to the poles right?
mrbohn1 said:picking 3 random numbers between 0 and 1 for the x,y and z coordinates sounds like a better bet...
D H said:Drawing sine(latitude) from U[-1,1] and longitude from U[0,360º) does the trick.
A good random number package will provide separate interfaces for drawing from U[0,1), U[0,1], U(0,1), and U(0,1]. A not so good one might only provide just one of these four. There are some very small drawbacks to using not quite the right interface. For example, drawing longitude from U[0,360º] gives a small chance of doubling up on 0 versus 360º. Drawing sine(latitude) from U[-1,1) means you ruled out the North Pole.