From: Anton S. <br...@po...> - 2008-12-23 04:40:00
|
Bruce Sherwood wrote: > However, be aware that the star positions aren't real, just > generated from random numbers (and there's an odd effect in > the random number generator, because a strong concentration in > the form of a straight bar shows up at certain angles of view). The fault in the stars lies not in the RNG. Uniform distribution of latitude gives a concentration toward the z axis. The code should be: theta = uniform(0,2*pi) zn = uniform(-1,1) # iota = acos(zn) rn = sqrt(1-zn**2) rho = uniform(rmn*a,rmx*a) rxy = rho*rn x = rxy*cos(theta) y = rxy*sin(theta) z = rho*zn Another way is x = normalvariate(mean,sigma) y = normalvariate(mean,sigma) z = normalvariate(mean,sigma) This has spherical symmetry but may not give the radial distribution you want. -- Anton Sherwood *\\* www.ogre.nu "How'd ya like to climb this high without no mountain?" --Porky Pine |