runif3: Generate randomly oriented vectors in 3D

Description Usage Arguments Value Author(s) See Also Examples

View source: R/runif3.R

Description

Generate randomly oriented vectors in 3D, following an isotropic distribution (optionally truncated to a region).

Usage

1
runif3(n = 1, r = c(0, 1), azimuth = c(0, 2 * pi), polarangle = c(0, pi))

Arguments

n

number of random vectors to be generated

r

2-vector specifying the range of radii

azimuth

2-vector specifying the range of azimuth angles (maximum range 0..2*pi)

polarangle

2-vector specifying the range of polar angles (maximum range 0..pi)

Value

Returns an n-by-3 array of n vectors.

Author(s)

Danail Obreschkow

See Also

runif2

Examples

1
2
3
## draw 20 unit vectors on a sphere
x = runif3(20,r=c(1,1))
print(rowSums(x^2))

physx documentation built on Feb. 3, 2022, 5:08 p.m.

Related to runif3 in physx...