powered by
Generate randomly oriented vectors in 3D, following an isotropic distribution (optionally truncated to a region).
runif3(n = 1, r = c(0, 1), azimuth = c(0, 2 * pi), polarangle = c(0, pi))
number of random vectors to be generated
2-vector specifying the range of radii
2-vector specifying the range of azimuth angles (maximum range 0..2*pi)
2-vector specifying the range of polar angles (maximum range 0..pi)
Returns an n-by-3 array of n vectors.
runif2
# NOT RUN { ## draw 20 unit vectors on a sphere x = runif3(20,r=c(1,1)) print(rowSums(x^2)) # }
Run the code above in your browser using DataLab